﻿/*
Research team: Norwegian Nga quantification company
Please contact our agency
*/
#property copyright "Telegram Telegram @vegasma169"
#property link "Telegram @vegasma169"
#property version "1.306"
#property strict
#property description "Advisor trade the average price return on non-trending pairs correlated with each other.\nUse ECN accounts with a minimum spread and commissions.\nWhen EA trades, many small transactions are simultaneously opened on the account.\nThis allows you to diversify trading entrances and exits from the market."

enum TypeOfSets
{
  Multi_Sets_123_sbig_15adv = 7,
  Multi_Sets_123_small_3adv = 6,
  Multi_Sets_123_big_9adv = 5,
  Multi_Set_3_3advisors = 4,
  Multi_Set_2_3advisors = 3,
  Multi_Set_1_3advisors = 2,
  Custom = 1
};
enum NY_Weekends
{
  days_0 = 2,
  days_7 = 1,
  days_14 = 0
};
enum FirstPositiontype
{
  NotOpen = 4,
  Short = 3,
  Long = 2,
  Long_and_Short = 1
};
enum TypeBFLC
{
  balance = 1,
  equity = 0
};
enum typeord
{
  all = -1,
  sell_stop = 5,
  buy_stop = 4,
  sell_limit = 3,
  buy_limit = 2,
  sell = 1,
  buy = 0
};

//---------------------
struct _sets
{
  string setName;
  int magicNumber;
  double martinMultiplier;
  double minProfitPercent;
  double maxDrawdownPercent;
  double riskPercent;
  double tpMultiplier;
  double reserved;
  void _sets_8();
  void _sets_9();
  void _sets_10();
  void _sets_11();
};
extern string _base_ = "=========Basic settings=========";
extern string MultiCurrency = "";            // OneChartSetup multi currency mode.
extern string comment = "new";               // Prefix for comment
extern FirstPositiontype FirstPositionp = 1; // First Position
extern bool fastClose = false;               // Emergency closing at breakeven
extern int nmbrThisServer = 1;               // For magic: 0 to 99
extern NY_Weekends holidays = 0;             // Duration of the weekend after the New Year
extern bool useVirtualTP = false;            // Using a virtual take-profit?
extern string _mm_ = "=========Money Management Settings=========";
extern int MaxOtherMagics = 0;      // Number of magics no more:
extern int MaxOtherSymbols = 0;     // Number of symbols no more:
extern TypeBFLC BaseForLotCalc = 0; // For autolot use
extern double virtBalance = 0;      // Additional funds in account currency
extern double fix_balance = 0;      // Or use fix balance in account currency
extern double USD_for_001 = 0;      // AutoMM. Aggressive=1000, Conservative=5000.
extern double Lots = 0.01;          // Fix lot if AutoMM=0
extern string _aver_ = "=========Averaging Settings=========";
extern bool UseUnloss = true;    // Recovery Mode
extern double LotsMartinp = 2.5; // Martin ratio
extern string _grid_ = "=========Grid Level Settings=========";
extern int FirstNumberp = 3; // First real deal from this level n>=0
string g_EAVersion = "1.306";
_sets g_SettingsArray[];
int g_SettingsMode = 7;
string g_CustomSettings = "";
int g_MaxAdvisors = 15;
bool g_ShowDashboard = true;
int g_TerminalType = 0;
int g_TotalAdvisors = 1;
int g_MagicConstant1 = -858993459;
int g_MagicConstant2 = 1072745676;
int g_MagicConstant3 = 1717986918;
short g_MagicConstant4 = 1072719462;
string g_ExecutionLabel = "=========Execution Settings=========";
int g_CurrentLevel = 0;
int g_MaxSlippage = 0;
bool g_UseECNMode = true;
double g_MaxSpread = 0.0;
int g_MaxRetries = 0;
int g_MinPipStep = 400;
int g_MaxPipStep = 800;
double g_LotMultiplier = 1.4;
int g_GridLevels = 14;
double g_MinProfitPercent = 0.0143;
bool g_UseGridTrading = true;
int g_CurrentMagic = 0;
int g_InternalMagic = 0;
int g_SetIndex = 0;
double g_TakeProfit1 = 0.7;
double g_TakeProfit2 = 0.9;
int g_TakeProfitPips = 70;
double g_StopLossMultiplier = 1.5;
double g_DrawdownPercent = 0.9;
double g_Reserved1 = 0.0;
double g_AutoMMFactor = 0.0;
double g_MinLotMultiplier = 1.0;
double g_DefaultLotSize = 1.0;
double g_MaxLotSize = 100.0;
string g_LotLimitLabel = "Настройки ограничения лота";
bool g_UseLotLimit = true;
double g_MaxLotPerTrade = 100.0;
bool g_UseDrawdownControl = true;
double g_MartinMultiplier = 0.0;
int g_RecoveryProfitPercent = 70;
int g_RecoveryLossPercent = 50;
int g_MaxRecoveryLevel = 6;
string g_TesterLabel = "=========Tester Settings=========";
bool g_TesterOption1 = false;
bool g_TesterOption2 = false;
bool g_TesterOption3 = false;
string g_CurrentSymbol = "";
int g_SymbolDigits = 0;
int g_LastBarTime = 0;
double g_AccountBalance = 0.0;
int g_TotalOrders = 0;
double g_MinPrice = 0.0;
double g_MaxPrice = 0.0;
double g_AveragePrice = 0.0;
double g_TotalLots = 0.0;
int g_BuyOrders = 0;
int g_SellOrders = 0;
int g_LastOrderType = 0;
int g_OrdersArrayIndex = 0;
int g_MaxOrdersInArray = 0;
int g_PendingBuyOrders = 0;
int g_PendingBuyLimitOrders = 0;
int g_PendingSellOrders = 0;
int g_PendingSellLimitOrders = 0;
int g_LastProcessedBar = 0;
double g_NextEntryPrice = 0.0;
int g_GridDistancePoints = 0;
int g_AccountStatus = 0;
double g_LastEquity = 0;
int g_ConsecutiveLosses = 0;
int g_ConsecutiveWins = 0;
int g_LastTicket = 0;
int g_ErrorCount = 0;
bool g_IsTradeAllowed = false;
int g_OrdersHistory[100][15];
int g_HistoryIndex = 0;
int g_LastUpdateTime = 0;
int g_ChartWindowIndex = 0;
int g_DashboardX = 0;
int g_DashboardY = 0;
int g_DashboardWidth = 0;
double g_OrderProfitArray[7][10000];
string g_OrderCommentArray[40000] = {};
int g_OrderTicketArray[40000];
int g_OrdersCount = 0;
int g_LastProcessedOrder = 0;
int g_TotalProcessedOrders = 0;
double g_TotalProfit = 0.0;
double g_MaxDrawdown = 0.0;
string g_AdvisorIndex;
int g_LoopCounter = 0;
int r1;
int g_TimerCounter = 0;
int g_LastCalculationTime = 0;
int g_InitializationStatus = 0;
int g_TotalSymbols = 1;
string g_SymbolsArray[1] = {};
double g_SymbolMultiplierArray[1];
bool g_IsM15Timeframe = true;
int g_FontSize = 0;
int g_ObjectCount = 0;
bool g_IsFirstRun = false;
bool g_IsRecoveryMode = false;
int g_RecoveryStep = 0;
int g_RecoveryAttempts = 0;
int g_LastErrorCode = 0;
int g_LastErrorTime = 0;
string g_LastErrorSymbol;
string g_LastErrorFunction;
string g_StatusText1 = "";
string g_StatusText2 = "";
int g_ColorConstant = 2263842;
int g_Reserved1 = 0;
int g_Reserved2 = 0;
string g_DrawdownStatus = "no_drawdown";
int g_Reserved4 = 0;
int g_Reserved5 = 0;
string g_Reserved6 = "";
bool g_Reserved7 = false;
double g_PriceGridArray[6][5][2];
bool g_GridEnabled = true;
string g_SymbolListArray[];
double g_SpreadValue = 0.0;
double g_SwapLong = 0.0;
double g_SwapShort = 0.0;
double g_PointValue = 0.0;
double g_TickValue = 0.0;
double g_MarginRequired = 0.0;
double g_LotStepArray[];

int OnInit()
{

  g_FontSize = TerminalInfoInteger(27) * 100 / 96;
  EventSetTimer(1);
  InitializeTerminal();
  if (Period() != 15)
  {
    Print("The adviser works only on the M15 period. Change the timeframe to M15");
    Alert("The adviser works only on the M15 period. Change the timeframe to M15 and restart advosor.");
    g_IsM15Timeframe = false;
  }
  else
  {
    g_IsM15Timeframe = true;
  }
  ArrayResize(g_SymbolMultiplierArray, 1, 0);
  ArrayResize(g_SymbolsArray, 1, 0);

  if (TrimString(MultiCurrency) != "" && !(IsTesting()))
  {
    SplitString(",", MultiCurrency, g_SymbolsArray);
    ParseSymbolMultipliers(g_SymbolsArray, g_SymbolMultiplierArray);
  }
  else
  {
    g_SymbolsArray[0] = Symbol();
    g_SymbolMultiplierArray[0] = g_DefaultLotSize;
  }
  g_TotalSymbols = ArraySize(g_SymbolsArray);
  if (IsTesting())
  {
    g_CurrentSymbol = Symbol();
  }

                        //setName magicNumber martinMultiplier minProfitPercent maxDrawdownPercent riskPercent tpMultiplier reserved
  _sets localStruct_2_160 = {"Set1-159", 159, 1.4, 0.4, 1, 50, 1.5, 0};
  _sets localStruct_3_160 = {"Set1-318", 318, 1.4, 0.4, 1, 50, 1.5, 0};
  _sets localStruct_4_160 = {"Set1-635", 635, 1.4, 0.4, 1, 50, 1.5, 0};
  _sets localStruct_5_160 = {"Set1-225", 225, 1.4, 0.4, 1, 50, 1.5, 0};
  _sets localStruct_6_160 = {"Set1-450", 450, 1.4, 0.4, 1, 50, 1.5, 0};
  _sets localStruct_7_160 = {"Set2-200", 200, 1.35, 0.7, 0.9, 70, 1.5, 0};
  _sets localStruct_8_160 = {"Set2-400", 400, 1.4, 0.7, 0.9, 70, 1.5, 0};
  _sets localStruct_9_160 = {"Set2-800", 800, 1.4, 0.65, 0.85, 30, 1.5, 0};
  _sets localStruct_10_160 = {"Set2-283", 283, 1.4, 0.7, 0.9, 70, 1.5, 0};
  _sets localStruct_11_160 = {"Set2-566", 566, 1.4, 0.7, 0.9, 70, 1.5, 0};
  _sets localStruct_12_160 = {"Set3-252", 252, 1.4, 0.9, 0.8, 60, 1.5, 0};
  _sets localStruct_13_160 = {"Set3-504", 504, 1.4, 0.9, 0.8, 60, 1.5, 0};
  _sets localStruct_14_160 = {"Set3-1008", 1008, 1.4, 0.85, 0.75, 20, 1.5, 0};
  _sets localStruct_15_160 = {"Set3-356", 356, 1.4, 0.9, 0.8, 60, 1.5, 0};
  _sets localStruct_16_160 = {"Set3-713", 713, 1.4, 0.85, 0.75, 20, 1.5, 0};
  _sets localStruct_17_160_ko[];

  if (g_SettingsMode == 1 && TrimString(g_CustomSettings) == "")
  {
    g_TotalAdvisors = 1;
  }
  else
  {
    if (g_SettingsMode == 1 && TrimString(g_CustomSettings) != "")
    {
      ParseSettingsString(g_CustomSettings, localStruct_17_160_ko);
      g_TotalAdvisors = ArraySize(localStruct_17_160_ko);
      CopySettingsArray(g_SettingsArray, localStruct_17_160_ko);
    }
    else
    {
      if (g_SettingsMode == 2)
      {
        ArrayResize(g_SettingsArray, 3, 0);
        g_TotalAdvisors = 3;
        CopySettingsStruct(g_SettingsArray[0], localStruct_2_160);
        CopySettingsStruct(g_SettingsArray[1], localStruct_3_160);
        CopySettingsStruct(g_SettingsArray[2], localStruct_4_160);
      }
      else
      {
        if (g_SettingsMode == 3)
        {
          ArrayResize(g_SettingsArray, 3, 0);
          g_TotalAdvisors = 3;
          CopySettingsStruct(g_SettingsArray[0], localStruct_7_160);
          CopySettingsStruct(g_SettingsArray[1], localStruct_8_160);
          CopySettingsStruct(g_SettingsArray[2], localStruct_9_160);
        }
        else
        {
          if (g_SettingsMode == 4)
          {
            ArrayResize(g_SettingsArray, 3, 0);
            g_TotalAdvisors = 3;
            CopySettingsStruct(g_SettingsArray[0], localStruct_12_160);
            CopySettingsStruct(g_SettingsArray[1], localStruct_13_160);
            CopySettingsStruct(g_SettingsArray[2], localStruct_14_160);
          }
          else
          {
            if (g_SettingsMode == 5)
            {
              ArrayResize(g_SettingsArray, 9, 0);
              g_TotalAdvisors = 9;
              CopySettingsStruct(g_SettingsArray[0], localStruct_2_160);
              CopySettingsStruct(g_SettingsArray[1], localStruct_3_160);
              CopySettingsStruct(g_SettingsArray[2], localStruct_4_160);
              CopySettingsStruct(g_SettingsArray[3], localStruct_7_160);
              CopySettingsStruct(g_SettingsArray[4], localStruct_8_160);
              CopySettingsStruct(g_SettingsArray[5], localStruct_9_160);
              CopySettingsStruct(g_SettingsArray[6], localStruct_12_160);
              CopySettingsStruct(g_SettingsArray[7], localStruct_13_160);
              CopySettingsStruct(g_SettingsArray[8], localStruct_14_160);
            }
            else
            {
              if (g_SettingsMode == 6)
              {
                ArrayResize(g_SettingsArray, 3, 0);
                g_TotalAdvisors = 3;
                CopySettingsStruct(g_SettingsArray[0], localStruct_3_160);
                CopySettingsStruct(g_SettingsArray[1], localStruct_8_160);
                CopySettingsStruct(g_SettingsArray[2], localStruct_13_160);
              }
              else
              {
                if (g_SettingsMode == 7)
                {
                  ArrayResize(g_SettingsArray, 15, 0);
                  g_TotalAdvisors = 15;
                  CopySettingsStruct(g_SettingsArray[0], localStruct_2_160);
                  CopySettingsStruct(g_SettingsArray[1], localStruct_3_160);
                  CopySettingsStruct(g_SettingsArray[2], localStruct_4_160);
                  CopySettingsStruct(g_SettingsArray[3], localStruct_5_160);
                  CopySettingsStruct(g_SettingsArray[4], localStruct_6_160);
                  CopySettingsStruct(g_SettingsArray[5], localStruct_7_160);
                  CopySettingsStruct(g_SettingsArray[6], localStruct_8_160);
                  CopySettingsStruct(g_SettingsArray[7], localStruct_9_160);
                  CopySettingsStruct(g_SettingsArray[8], localStruct_10_160);
                  CopySettingsStruct(g_SettingsArray[9], localStruct_11_160);
                  CopySettingsStruct(g_SettingsArray[10], localStruct_12_160);
                  CopySettingsStruct(g_SettingsArray[11], localStruct_13_160);
                  CopySettingsStruct(g_SettingsArray[12], localStruct_14_160);
                  CopySettingsStruct(g_SettingsArray[13], localStruct_15_160);
                  CopySettingsStruct(g_SettingsArray[14], localStruct_16_160);
                }
              }
            }
          }
        }
      }
    }
  }
  g_AutoMMFactor = (USD_for_001 == 0.0) ? 0.0 : 1000.0 / USD_for_001 / g_TotalAdvisors;
  if (!(UseUnloss))
  {
    g_RecoveryProfitPercent = 7;
    g_RecoveryLossPercent = 5;
  }
  if (g_ShowDashboard && (!(IsTesting()) || IsVisualMode()))
  {
    CreateDashboardPanel();
  }
  InitializeArrays();
  HideTestIndicators(true);
  for (int localInt_18 = 0; localInt_18 < g_TotalSymbols; localInt_18++)
  {
    g_CurrentSymbol = g_SymbolsArray[localInt_18];
    for (int localInt_19 = 1; localInt_19 <= g_TotalAdvisors; localInt_19++)
    {
      g_AdvisorIndex = IntegerToString(localInt_19, 2, 48);

      g_InternalMagic = StringToInteger(GetSymbolPrefix(g_CurrentSymbol) + g_AdvisorIndex);
      g_CurrentMagic = StringToInteger(GetMagicSuffix(g_AdvisorIndex));
      GlobalVariableSet(string(IsTesting()) + "Magic" + g_CurrentSymbol + string(g_InternalMagic), g_CurrentMagic);
      g_OrderProfitArray[3][0] = AccountEquity();
    }
  }
  return (0);
}
// OnInit <<==--------   --------
void OnTick()
{

  if (!(g_IsM15Timeframe) && !(IsTesting()))
  {
    Print("The adviser adapted only on the M15 period. Change the timeframe to M15");
  }
  for (int j = 0; j < g_TotalSymbols; j++)
  {

    g_CurrentSymbol = (g_SymbolsArray[j]);

    if (g_CurrentSymbol == "")
      continue;
    g_DefaultLotSize = g_SymbolMultiplierArray[j];
    if (MarketInfo(g_CurrentSymbol, 9) == 0.0)
      continue;
    int i = 1;
    if (g_TotalAdvisors < 1)
      continue;
    for (; i <= g_TotalAdvisors; i++)
    {
      if (useVirtualTP)
      {
        if (CheckOrderExists(g_CurrentSymbol, -1, -1, 0, ""))
        {
          EmergencyHandler(i);
          CloseAllPositions();
        }
      }
      if (fastClose)
      {
        if (CheckOrderExists(g_CurrentSymbol, -1, -1, 0, ""))
        {
          EmergencyHandler(i);
          if (GetOrderComment(g_CurrentSymbol, -1, g_CurrentMagic) > 0.0)
          {
            CloseOrdersByType(g_CurrentSymbol, -1, g_CurrentMagic);
          }
        }
      }
      if (g_OrdersHistory[i][j] == iTime(g_CurrentSymbol, 0, 0))
        continue;
      EmergencyHandler(i);
      if (i == 1 && (g_TesterOption1 || g_TesterOption3))
      {
        if (TimeDay(iTime(g_CurrentSymbol, 0, 0)) != TimeDay(iTime(g_CurrentSymbol, 0, 1)) && IsTesting())
        {
          g_OrderProfitArray[0][g_LastProcessedOrder] = iTime(g_CurrentSymbol, 0, 0);
          g_OrderProfitArray[1][g_LastProcessedOrder] = AccountBalance();
          g_OrderProfitArray[2][g_LastProcessedOrder] = AccountEquity();
          g_OrderProfitArray[3][g_LastProcessedOrder + 1] = AccountEquity();
          g_OrderProfitArray[5][g_LastProcessedOrder] = AccountMargin() * (AccountLeverage() / 100);
          g_OrderProfitArray[6][g_LastProcessedOrder + 1] = AccountMargin() * (AccountLeverage() / 100);
          g_LastProcessedOrder++;
        }
        if (AccountEquity() < g_OrderProfitArray[3][g_LastProcessedOrder])
        {
          g_OrderProfitArray[3][g_LastProcessedOrder] = AccountEquity();
        }
        if (AccountMargin() * (AccountLeverage() / 100) > g_OrderProfitArray[6][g_LastProcessedOrder])
        {
          g_OrderProfitArray[6][g_LastProcessedOrder] = AccountMargin() * (AccountLeverage() / 100);
        }
      }
      if (CheckDrawdownLimit(0) && MathMax(iHigh(g_CurrentSymbol, 0, 1), g_SwapShort) >= GlobalVariableGet(string(IsTesting()) + g_CurrentSymbol + string(g_InternalMagic) + "tp"))
      {
        GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "0" + string(g_InternalMagic), 0.0);
        GlobalVariableSet(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic), 0.0);
        ObjectDelete(0, g_CurrentMagic);
      }
      if (CheckDrawdownLimit(1) && MathMin(iLow(g_CurrentSymbol, 0, 1) + g_SwapLong - g_SwapShort, g_SwapLong) <= GlobalVariableGet(string(IsTesting()) + g_CurrentSymbol + string(g_InternalMagic) + "tp"))
      {
        GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "1" + string(g_InternalMagic), 0.0);
        GlobalVariableSet(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic), 0.0);
        ObjectDelete(0, g_CurrentMagic);
      }
      
      if (g_MinPrice == 0.0)
        continue;

      if (g_UseDrawdownControl && g_GridEnabled)
      {
        ManageAddPosition();
      }
      g_AccountStatus = GetAccountStatus();
      int i3 = 0;
      double i5 = 0;
      double i7 = 0;
      if (CheckOrderExists(g_CurrentSymbol, -1, g_CurrentMagic, 0, ""))
        continue;
      if (IsFirstPositionAllowed() || !(g_GridEnabled))
        continue;
      if (CheckHolidayRestriction() != "")
        continue;
      g_IsTradeAllowed = false;
      int localInt_8 = 0;
      if (g_AccountStatus == 1)
      {
        int localInt_9 = 0;
        if (FirstNumberp > g_CurrentLevel)
        {
          GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "0" + string(g_InternalMagic), 1.0);
          localInt_9 = 1;
          localInt_8 = -1;
          Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " The opened grid level is less than the minimum level. The deal is virtualized");
        }
        else
        {
          if (CalculateLotSize(1.0, true) < 0.01)
          {
            GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "0" + string(g_InternalMagic), 1.0);
            localInt_9 = 1;
            localInt_8 = -1;
            Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " Current lot <0.01. The deal is virtualized");
          }
          else
          {
            if (MaxOtherMagics > 0)
            {
              if (CountOtherMagics(g_CurrentMagic, "") >= MaxOtherMagics)
              {
                GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "0" + string(g_InternalMagic), 1.0);
                localInt_9 = 1;
                localInt_8 = -1;
                Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " GetOtherMagicsCount >= MaxOtherMagics. The deal is virtualized");
              }
            }
            else
            {
              if (MaxOtherSymbols > 0)
              {
                if (CountOtherSymbols(g_CurrentSymbol) >= MaxOtherSymbols)
                {
                  GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "0" + string(g_InternalMagic), 1.0);
                  localInt_9 = 1;
                  localInt_8 = -1;
                  Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " GetOtherSymbolsCountt >= MaxOtherSymbols. The deal is virtualized");
                }
              }
              else
              {
                localInt_8 = OpenPosition(g_CurrentSymbol, 0, CalculateLotSize(1.0, true), 0, 0, g_CurrentMagic, "C0", 0.0);
                if (localInt_8 > 0)
                {
                  localInt_9 = 1;
                }
              }
            }
          }
        }
        if (localInt_9 == 1)
        {
          lizong80(localInt_8);
          g_GridDistancePoints = (g_MinPrice - g_MaxPrice) / g_PointValue;
          g_NextEntryPrice = MathMin(iClose(g_CurrentSymbol, 0, 1), g_SwapShort) + g_SwapLong - g_SwapShort - g_GridDistancePoints * g_PointValue;
          GlobalVariableSet(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic), 0.0);
          GlobalVariableSet(string(IsTesting()) + "Distance_Price" + g_CurrentSymbol + string(g_InternalMagic), g_NextEntryPrice);
          UpdateGridDistance();
        }
      }
      if (g_AccountStatus != 2)
        continue;

      if (FirstNumberp > g_CurrentLevel)
      {
        GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "1" + string(g_InternalMagic), 1.0);
        i3 = 1;
        localInt_8 = -1;
        Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " The opened grid level is less than the minimum level. The deal is virtualized");
      }
      else
      {
        if (CalculateLotSize(1.0, true) < 0.01)
        {
          GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "1" + string(g_InternalMagic), 1.0);
          i3 = 1;
          localInt_8 = -1;
          Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " Current lot <0.01. The deal is virtualized");
        }
        else
        {
          if (MaxOtherMagics > 0)
          {
            if (CountOtherMagics(g_CurrentMagic, "") >= MaxOtherMagics)
            {
              GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "1" + string(g_InternalMagic), 1.0);
              i3 = 1;
              localInt_8 = -1;
              Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " GetOtherMagicsCount >= MaxOtherMagics. The deal is virtualized");
            }
          }
          else
          {
            if (MaxOtherSymbols > 0)
            {
              if (CountOtherSymbols(g_CurrentSymbol) >= MaxOtherSymbols)
              {
                GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "1" + string(g_InternalMagic), 1.0);
                i3 = 1;
                localInt_8 = -1;
                Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " GetOtherSymbolsCountt >= MaxOtherSymbols. The deal is virtualized");
              }
            }
            else
            {
              localInt_8 = OpenPosition(g_CurrentSymbol, 1, CalculateLotSize(1.0, true), 0, 0, g_CurrentMagic, "C0", 0.0);
              if (localInt_8 > 0)
              {
                i3 = 1;
              }
            }
          }
        }
      }
      if (i3 != 1)
        continue;
      lizong80(localInt_8);

      g_GridDistancePoints = (g_MinPrice - g_MaxPrice) / g_PointValue;
      g_NextEntryPrice = MathMax(iClose(g_CurrentSymbol, 0, 1), g_SwapShort) + g_GridDistancePoints * g_PointValue;
      GlobalVariableSet(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic), 0.0);
      GlobalVariableSet(string(IsTesting()) + "Distance_Price" + g_CurrentSymbol + string(g_InternalMagic), g_NextEntryPrice);
      UpdateGridDistance();
    }
  }

  for (int localInt_10 = 0; localInt_10 < g_TotalSymbols; localInt_10++)
  {
    g_CurrentSymbol = g_SymbolsArray[localInt_10];
    g_DefaultLotSize = g_SymbolMultiplierArray[localInt_10];
    if (MarketInfo(g_CurrentSymbol, 9) == 0.0)
      continue;
        int i11 = 1;
    if (g_TotalAdvisors < 1)
      continue;
    for (; i11 <= g_TotalAdvisors; i11++)
    {

      if (localInt_11 == g_TotalAdvisors && localInt_10 == g_TotalSymbols - 1 && !(IsTesting()) && g_ShowDashboard && (!(IsTesting()) || IsVisualMode()))
      {
        UpdateDashboardInfo();
      }
      if (g_OrdersHistory[localInt_11][localInt_10] == iTime(g_CurrentSymbol, 0, 0))
        continue;
      g_OrdersHistory[localInt_11][localInt_10] = iTime(g_CurrentSymbol, 0, 0);
      if (localInt_11 == g_TotalAdvisors && localInt_10 == g_TotalSymbols - 1 && IsTesting() && g_ShowDashboard && (!(IsTesting()) || IsVisualMode()))
      {
        UpdateDashboardInfo();
      }
      EmergencyHandler(localInt_11);
      if (CheckOrderExists(g_CurrentSymbol, 0, g_CurrentMagic, 0, "") || CheckDrawdownLimit(0))
      {

        g_TotalProfit = MathPow(g_StopLossMultiplier, MathLog(g_MaxRetries / 100.0) / 0.6931471805599) * g_TakeProfitPips / MathPow(g_StopLossMultiplier, 2.0) * g_SwapShort * 0.00001 + CalculateBreakeven(0, g_CurrentMagic);
        g_MaxDrawdown = MathPow(g_StopLossMultiplier, MathLog(g_MaxRetries / 100.0) / 0.6931471805599) * g_TakeProfitPips / MathPow(g_StopLossMultiplier, 2.0) * g_SwapShort * 0.00001 + g_TakeProfit1 * MathPow(g_TakeProfit2, g_CurrentLevel) * (g_MaxPrice - g_SwapShort) + g_SwapLong;
        if (UseUnloss)
        {
          g_AccountBalance = !CheckOrderExists(g_CurrentSymbol, 0, g_CurrentMagic, 0, "") ? g_MaxDrawdown : MathMax(g_TotalProfit, g_MaxDrawdown);

          g_AccountBalance = (g_CurrentLevel >= g_MaxRecoveryLevel) ? g_TotalProfit : g_AccountBalance;
        }
        else
        {
          g_AccountBalance = g_MaxDrawdown;
        }
        if (!(useVirtualTP))
        {
          SetVirtualTakeProfit(0, g_CurrentMagic, g_AccountBalance);
        }
        else
        {
          SetVirtualTakeProfit(0, g_CurrentMagic, 0.0);
        }
        GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + string(g_InternalMagic) + "tp", g_AccountBalance);
        double localDouble_12 = GlobalVariableGet(string(IsTesting()) + g_CurrentSymbol + string(g_InternalMagic) + "peak");
        if ((iLow(g_CurrentSymbol, 0, 1) < localDouble_12 || localDouble_12 == 0.0))
        {
          localDouble_12 = iLow(g_CurrentSymbol, 0, 1);
          GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + string(g_InternalMagic) + "peak", localDouble_12);
        }
        if (g_MaxPrice - localDouble_12 != 0.0 && (g_SwapShort - localDouble_12) / (g_MaxPrice - localDouble_12) > g_DrawdownPercent)
        {
          if ((!(UseUnloss) || (GetOrderComment(g_CurrentSymbol, 0, g_CurrentMagic) > 0.0 && UseUnloss)))
          {
            CloseOrdersByType(g_CurrentSymbol, -1, g_CurrentMagic);
            if (!CheckOrderExists(g_CurrentSymbol, -1, g_CurrentMagic, 0, ""))
            {
              GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "0" + string(g_InternalMagic), 0.0);
              GlobalVariableSet(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic), 0.0);
            }
          }
        }
      }
      if (!CheckOrderExists(g_CurrentSymbol, 1, g_CurrentMagic, 0, ""))
      {
        if (!(CheckDrawdownLimit(1)))
          continue;
      }
      g_TotalProfit = CalculateBreakeven(1, g_CurrentMagic) - MathPow(g_StopLossMultiplier, MathLog(g_MaxRetries / 100.0) / 0.6931471805599) * g_TakeProfitPips / MathPow(g_StopLossMultiplier, 2.0) * g_SwapShort * 0.00001;
      g_MaxDrawdown = g_SwapShort - g_TakeProfit1 * MathPow(g_TakeProfit2, g_CurrentLevel) * (g_SwapShort - g_MaxPrice) - MathPow(g_StopLossMultiplier, MathLog(g_MaxRetries / 100.0) / 0.6931471805599) * g_TakeProfitPips / MathPow(g_StopLossMultiplier, 2.0) * g_SwapShort * 0.00001;
      if (UseUnloss)
      {
        g_AccountBalance = !CheckOrderExists(g_CurrentSymbol, 1, g_CurrentMagic, 0, "") ? g_MaxDrawdown : MathMin(g_TotalProfit, g_MaxDrawdown);
        g_AccountBalance = (g_CurrentLevel >= g_MaxRecoveryLevel) ? g_TotalProfit : g_AccountBalance;
      }
      else
      {
        g_AccountBalance = g_MaxDrawdown;
      }
      if (!(useVirtualTP))
      {
        SetVirtualTakeProfit(1, g_CurrentMagic, g_AccountBalance);
      }
      else
      {
        SetVirtualTakeProfit(1, g_CurrentMagic, 0.0);
      }
      GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + string(g_InternalMagic) + "tp", g_AccountBalance);
      double localDouble_12 = GlobalVariableGet(string(IsTesting()) + g_CurrentSymbol + string(g_InternalMagic) + "peak");
      if ((iHigh(g_CurrentSymbol, 0, 1) > localDouble_12 || localDouble_12 == 0.0))
      {
        localDouble_12 = iHigh(g_CurrentSymbol, 0, 1);
        GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + string(g_InternalMagic) + "peak", localDouble_12);
      }
      double localDouble_13 = SymbolInfoDouble(g_CurrentSymbol, 1);
      if (!(localDouble_13 > 0.0))
        continue;
      double localDouble_14 = ((SymbolInfoDouble(g_CurrentSymbol, 4) - localDouble_13) / localDouble_13) * 100000.0;
      if (!((localDouble_12 - g_MaxPrice) != 0.0) || !(localDouble_14 < 50.0) || !((localDouble_12 - g_SwapShort) / (localDouble_12 - g_MaxPrice) > g_DrawdownPercent))
        continue;

      if (UseUnloss)
      {
        if ((!(GetOrderComment(g_CurrentSymbol, 1, g_CurrentMagic) > 0.0) || !(UseUnloss)))
          continue;
      }
      CloseOrdersByType(g_CurrentSymbol, -1, g_CurrentMagic);
      if (CheckOrderExists(g_CurrentSymbol, -1, g_CurrentMagic, 0, ""))
        continue;
      GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "1" + string(g_InternalMagic), 0.0);
      GlobalVariableSet(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic), 0.0);
    }
  }
  if (!(g_ShowDashboard))
    return;

  if ((IsTesting() && !(IsVisualMode())))
    return;
  UpdateDashboardInfo();
}
// OnTick <<==--------   --------
void OnTimer()
{
  if (IsTesting())
    return;
  UpdateDashboardInfo();
}
// OnTimer <<==--------   --------
double OnTester()
{
  ArrayResize(g_LotStepArray, g_LastProcessedOrder - 1, 0);
  for (int localInt_2 = 1; localInt_2 < g_LastProcessedOrder; localInt_2++)
  {
    g_LotStepArray[localInt_2 - 1] = g_OrderProfitArray[3][localInt_2] / g_OrderProfitArray[3][localInt_2 - 1] - 1.0;
  }
  ArraySetAsSeries(g_LotStepArray, true);
  double localDouble_3 = iMAOnArray(g_LotStepArray, 0, g_LastProcessedOrder - 1, 0, 0, 0);
  double localDouble_4 = iStdDevOnArray(g_LotStepArray, 0, g_LastProcessedOrder - 1, 0, 0, 0);
  if (localDouble_4 != 0.0)
  {
    return (localDouble_3 / localDouble_4);
  }
  return (0.0);
}
// OnTester <<==--------   --------
int deinit()
{
  if (IsTesting() && g_TesterOption1)
  {
    GetOrdersCount();
  }
  if (IsTesting() && g_TesterOption2)
  {
    GetOrdersProfit();
  }
  for (int localInt_2 = 0; localInt_2 < g_TotalSymbols; localInt_2++)
  {
    g_CurrentSymbol = g_SymbolsArray[localInt_2];
    for (int localInt_3 = 1; localInt_3 <= g_TotalAdvisors; localInt_3++)
    {
      g_AdvisorIndex = IntegerToString(localInt_3, 2, 48);
      g_InternalMagic = StringToInteger((StringLen(g_CurrentSymbol) != 6) ? "99" : CurrencyToIndex(StringSubstr(g_CurrentSymbol, 0, 3)) + CurrencyToIndex(StringSubstr(g_CurrentSymbol, 3, 3)) + g_AdvisorIndex);
      if (IsTesting())
      {
        GlobalVariableDel(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic));
        GlobalVariableDel(string(IsTesting()) + "iBands_period" + g_CurrentSymbol + string(g_InternalMagic));
        GlobalVariableDel(string(IsTesting()) + "Distance_Price" + g_CurrentSymbol + string(g_InternalMagic));
        GlobalVariableDel(string(IsTesting()) + g_CurrentSymbol + string(g_InternalMagic) + "peak");
        GlobalVariableDel(string(IsTesting()) + "Magic" + g_CurrentSymbol + string(g_InternalMagic));
        GlobalVariableDel(string(IsTesting()) + g_CurrentSymbol + string(g_InternalMagic) + "tp");
        GlobalVariableDel(string(IsTesting()) + g_CurrentSymbol + "0" + string(g_InternalMagic));
        GlobalVariableDel(string(IsTesting()) + g_CurrentSymbol + "1" + string(g_InternalMagic));
      }
    }
  }
  return (0);
}
// deinit <<==--------   --------
int GetAccountStatus()
{
  //  int       localInt_1;
  int localInt_2 = 0;
  //----- -----

  g_TickValue = MarketInfo(g_CurrentSymbol, 13);
  g_SpreadValue = MarketInfo(g_CurrentSymbol, 13) * MarketInfo(g_CurrentSymbol, 11);
  g_SwapLong = MarketInfo(g_CurrentSymbol, 10);
  g_SwapShort = MarketInfo(g_CurrentSymbol, 9);
  g_PointValue = MarketInfo(g_CurrentSymbol, 11);
  g_MarginRequired = 0.0;
  if (iClose(g_CurrentSymbol, 0, 1) > 0.0)
  {
    g_MarginRequired = (MathAbs(g_SwapShort / iClose(g_CurrentSymbol, 0, 1) - 1.0)) * 10000.0;
  }
  if (g_SwapShort > g_MinPrice)
  {
    ObjectDelete(0, "DD");
    if ((FirstPositionp == 1 || FirstPositionp == 3))
    {
      localInt_2 = 2;
      g_AccountBalance = 0.00001 / g_PointValue * MathPow(g_StopLossMultiplier, MathLog(g_MaxRetries / 100.0) / 0.6931471805599) * g_TakeProfitPips / MathPow(g_StopLossMultiplier, 2.0) * g_SwapShort + g_TakeProfit1 * MathPow(g_TakeProfit2, g_CurrentLevel) * (g_SwapShort - g_MaxPrice) / g_PointValue;
    }
  }
  if (g_SwapLong < g_AveragePrice)
  {
    ObjectDelete(0, "DD");
    if ((FirstPositionp == 1 || FirstPositionp == 2))
    {
      localInt_2 = 1;
      g_AccountBalance = 0.00001 / g_PointValue * MathPow(g_StopLossMultiplier, MathLog(g_MaxRetries / 100.0) / 0.6931471805599) * g_TakeProfitPips / MathPow(g_StopLossMultiplier, 2.0) * g_SwapShort + g_TakeProfit1 * MathPow(g_TakeProfit2, g_CurrentLevel) * (g_MaxPrice - g_SwapShort) / g_PointValue;
    }
  }
  return (localInt_2);
}
// GetAccountStatus <<==--------   --------
void ResetGlobalVariables()
{

  g_TotalLots = iStdDev(g_CurrentSymbol, 0, g_MaxRetries, 1, 3, 0, -1) * g_LotMultiplier;
  if (g_UseGridTrading == true)
  {
    double localDouble_1 = GetMaxOrderLevel(g_CurrentLevel, g_MaxRetries);

    if (localDouble_1 > 0.0)
    {
      g_TotalLots = MathMax(g_TotalLots, localDouble_1);
    }
  }
  g_MaxPrice = iMA(g_CurrentSymbol, 0, g_MaxRetries, 1, 3, 0, -1);

  g_MinPrice = g_MaxPrice + g_TotalLots;
  g_AveragePrice = g_MaxPrice - g_TotalLots;
  g_LastBarTime = g_SetIndex;
}
// ResetGlobalVariables <<==--------   --------
void ModifyOrder(double param0_do, double param1_do, double param2_do, datetime param3_拆da)
{
  bool localBool_1 = false;
  double localDouble_2 = 0.0;
  double localDouble_3 = 0.0;
  double localDouble_4 = 0.0;
  double localDouble_5 = 0.0;
  double localDouble_6 = 0.0;
  //----- -----

  int localInt_7 = MarketInfo(OrderSymbol(), 12);
  int localInt_8 = 0;
  int localInt_9 = 0;
  string localString_10 = " Автор функции для:";
  if (param0_do <= 0.0)
  {
    param0_do = OrderOpenPrice();
  }
  if (param1_do < 0.0)
  {
    param1_do = OrderStopLoss();
  }
  if (param2_do < 0.0)
  {
    param2_do = OrderTakeProfit();
  }
  param0_do = NormalizeDouble(param0_do, localInt_7);
  param1_do = NormalizeDouble(param1_do, localInt_7);
  param2_do = NormalizeDouble(param2_do, localInt_7);
  localDouble_2 = NormalizeDouble(OrderOpenPrice(), localInt_7);
  localDouble_5 = NormalizeDouble(OrderStopLoss(), localInt_7);
  localDouble_6 = NormalizeDouble(OrderTakeProfit(), localInt_7);
  if ((!(param0_do != localDouble_2) && !(param1_do != localDouble_5) && !(param2_do != localDouble_6)))
    return;
  for (localInt_9 = 1; localInt_9 <= 5; localInt_9++)
  {
    if ((!(IsTesting()) && (!(IsExpertEnabled()) || IsStopped() != 0)))
      return;
    RefreshRates();
    localBool_1 = OrderModify(OrderTicket(), param0_do, param1_do, param2_do, param3_拆da, -1);
    if (localBool_1)
      return;
    localInt_8 = GetLastError();
    localDouble_3 = MarketInfo(OrderSymbol(), 10);
    localDouble_4 = MarketInfo(OrderSymbol(), 9);
    PrintFormat("Error(" + string(localInt_8) + ") modifying order: " + GetErrorDescription(localInt_8) + ", try " + string(localInt_9));
    PrintFormat("Ask=" + string(localDouble_3) + "  Bid=" + string(localDouble_4) + "  sy=" + OrderSymbol() + "  op=" + string(OrderType()) + "  pp=" + string(param0_do) + "  sl=" + string(param1_do) + "  tp=" + string(param2_do));
    do
    {
      if ((localInt_8 != 146 || !(IsTradeContextBusy())))
        continue;
      Sleep(500);
    } while (IsTradeContextBusy());
  }
}
// ModifyOrder <<==--------   --------
int OpenPosition(string param0_st, int param1_in, double param2_do, double param3_do, double param4_do, int param5_in, string param6_st, double param7_do)
{
  int localInt_1;
  color localColor_2 = 0;
  long localLong_3 = 0;
  double localDouble_4 = 0.0;
  double localDouble_5 = 0.0;
  double localDouble_6 = 0.0;
  double localDouble_7 = 0.0;
  int localInt_8 = 0;
  int localInt_9 = 0;
  int localInt_10 = 0;
  int localInt_11 = 0;
  string localString_12;
  string localString_13;
  double localDouble_14;
  double localDouble_15;
  string localString_16;
  MqlDateTime localStruct_17_129;
  MqlDateTime localStruct_18_129;
  //----- -----
  string tempst_1;
  bool tempbo_2;
  string tempst_3;
  bool tempbo_4;
  bool tempbo_5;
  string tempst_6;
  bool tempbo_7;
  bool tempbo_8;
  string tempst_9;
  bool tempbo_10;
  bool tempbo_11;
  bool tempbo_12;
  bool tempbo_13;
  double tempdo_14;
  bool tempbo_15;
  bool tempbo_16;
  int tempin_17;
  int tempin_18;
  string tempst_19;
  int tempin_20;
  int tempin_21;
  string tempst_22;
  int tempin_23;
  bool tempbo_24;

  localString_12 = "";
  if ((param0_st == "" || param0_st == "0"))
  {
    param0_st = g_CurrentSymbol;
  }
  if (param1_in == 0)
  {
    localColor_2 = 32768;
  }
  else
  {
    localColor_2 = 255;
  }
  localString_13 = " Автор функции: ";
  localDouble_14 = param2_do;
  localDouble_15 = 0.0;
  if (AccountFreeMarginCheck(param0_st, param1_in, param2_do) < 0.0)
  {
    tempst_1 = (param1_in == 0) ? "Buy" : "Sell";
    Print("Not enough money for ", tempst_1, " ", param2_do, " ", param0_st, " Error code=", GetLastError());
    tempbo_2 = false;
  }
  else
  {
    tempbo_2 = true;
  }
  if (!(tempbo_2))
  {
    Sleep(1000);
    if (AccountFreeMarginCheck(param0_st, param1_in, param2_do) < 0.0)
    {
      tempst_3 = (param1_in == 0) ? "Buy" : "Sell";
      Print("Not enough money for ", tempst_3, " ", param2_do, " ", param0_st, " Error code=", GetLastError());
      tempbo_4 = false;
    }
    else
    {
      tempbo_4 = true;
    }
    if (!(tempbo_4))
    {
      return (-1);
    }
  }
  if (AccountInfoInteger(ACCOUNT_LIMIT_ORDERS) == 0)
  {
    tempbo_5 = true;
  }
  else
  {
    tempbo_5 = OrdersTotal() < AccountInfoInteger(ACCOUNT_LIMIT_ORDERS);
  }
  if (!(tempbo_5))
  {
    PrintFormat("Amount of open and pending orders has reached the limit.");
    return (-1);
  }
  if ((MQLInfoString(MQL_PROGRAM_NAME) == "North East Way EA" || MQLInfoString(MQL_PROGRAM_NAME) == "NorthEastWay_v" + g_EAVersion || MQLInfoString(MQL_PROGRAM_NAME) == "NorthEastWay" || MQLInfoString(MQL_PROGRAM_NAME) == "NorthEastWay EA crypto"))
  {
    tempbo_7 = true;
  }
  else
  {
    tempbo_7 = false;
  }

  TimeToStruct(iTime(NULL, 0, 0), localStruct_17_129);
  if (((localStruct_17_129.year > 2021 && localStruct_17_129.mon > 6) || localStruct_17_129.year > 2022))
  {
    if ((TerminalInfoInteger(23) != 0 || TerminalInfoInteger(38) != 0))
    {
      tempbo_8 = true;
    }
    else
    {
      tempbo_8 = false;
    }
    if (!(tempbo_8))
    {
      if (MQLInfoString(MQL_PROGRAM_NAME) == "NorthEastWay")
      {
        tempbo_10 = true;
      }
      else
      {
        tempbo_10 = false;
      }
      if (!(tempbo_10))
      {
        tempbo_11 = false;
      }
    }
  }
  else
  {
    tempbo_11 = true;
  }
  if ((!(tempbo_7) || !(tempbo_11)) && !(IsTesting()) && AccountInfoInteger(ACCOUNT_TRADE_MODE) == 2 && param2_do > 0.1 && FirstNumberp + 1 <= g_CurrentLevel + 1)
  {
    return (1);
  }
  TimeToStruct(iTime(NULL, 0, 0), localStruct_18_129);
  if (((localStruct_18_129.year > 2021 && localStruct_18_129.mon > 12) || localStruct_18_129.year > 2022))
  {
    tempbo_12 = false;
  }
  else
  {
    tempbo_12 = true;
  }
  if (!(tempbo_12) && !(IsTesting()) && param2_do > 0.1 && FirstNumberp <= g_CurrentLevel + 1)
  {
    return (1);
  }
  g_MaxLotPerTrade = SymbolInfoDouble(param0_st, 35);
  while (localDouble_15 != param2_do)
  {
    if (param2_do > g_MaxLotPerTrade && g_UseLotLimit)
    {
      localDouble_14 = MathMin(param2_do - localDouble_15, g_MaxLotPerTrade);
      if (localDouble_14 > g_MaxLotPerTrade)
      {
        localDouble_14 = g_MaxLotPerTrade;
      }
    }
    if (localDouble_14 < SymbolInfoDouble(g_CurrentSymbol, 34))
    {
      localString_16 = StringFormat("Volume is less than the minimum SYMBOL_VOLUME_MIN=%.2f", SymbolInfoDouble(g_CurrentSymbol, 34));
      tempbo_13 = false;
    }
    else
    {
      if (localDouble_14 > SymbolInfoDouble(g_CurrentSymbol, 35))
      {
        localString_16 = StringFormat("Volume is greater than the maximum allowed SYMBOL_VOLUME_MAX=%.2f", SymbolInfoDouble(g_CurrentSymbol, 35));
        tempbo_13 = false;
      }
      else
      {
        if (MathAbs(int(MathRound(localDouble_14 / SymbolInfoDouble(g_CurrentSymbol, 36))) * SymbolInfoDouble(g_CurrentSymbol, 36) - localDouble_14) > 0.0000001)
        {
          localString_16 = StringFormat("Volume is not a multiple of the minimum gradation SYMBOL_VOLUME_STEP=%.2f, nearest correct volume %.2f", SymbolInfoDouble(g_CurrentSymbol, 36), int(MathRound(localDouble_14 / SymbolInfoDouble(g_CurrentSymbol, 36))) * SymbolInfoDouble(g_CurrentSymbol, 36));
          tempbo_13 = false;
        }
        else
        {
          localString_16 = "Correct volume";
          tempbo_13 = true;
        }
      }
    }
    if (!(tempbo_13))
    {
      PrintFormat(localString_16);
      return (-1);
    }
    for (localInt_10 = 1; localInt_10 <= 5; localInt_10++)
    {
      if ((!(IsTesting()) && (!(IsExpertEnabled()) || IsStopped() != 0)))
        break;

      while (!(IsTradeAllowed()))
      {
        if (IsTesting() || IsOptimization())
          continue;
        Sleep(5000);
      }
      RefreshRates();
      localInt_8 = MarketInfo(param0_st, 12);
      localDouble_5 = MarketInfo(param0_st, 10);
      localDouble_6 = MarketInfo(param0_st, 9);
      localDouble_7 = MarketInfo(param0_st, 13) * MarketInfo(param0_st, 11) / localDouble_6 * 10000.0;
      if (param1_in == 0)
      {
        localDouble_4 = localDouble_5;
      }
      else
      {
        localDouble_4 = localDouble_6;
      }
      localDouble_4 = NormalizeDouble(localDouble_4, localInt_8);
      localLong_3 = TimeCurrent();

      if ((param1_in == 0 && localDouble_5 <= param7_do) && (param1_in == 1 && localDouble_6 >= param7_do) && (param7_do == 0.0))

      {
        Print("Price does not match the distance, try ", localInt_10);
        Print("Ask=", localDouble_5, " Bid=", localDouble_6, " sy=", param0_st, " lot=", localDouble_14, " op=", param1_in, " pp=", localDouble_4, " sl=", param3_do, " tp=", param4_do, " mn=", param5_in, " price_dist=", param7_do);
        Sleep(7700);
        continue;
      }
      if (g_MaxSpread > 0.0 && localDouble_7 > g_MaxSpread)
      {
        Print("The current spread is greater than the maximum, try ", localInt_10);
        Print("Ask=", localDouble_5, " Bid=", localDouble_6, " sy=", param0_st, " lot=", localDouble_14, " op=", param1_in, " pp=", localDouble_4, " sl=", param3_do, " tp=", param4_do, " mn=", param5_in, " price_dist=", param7_do, " max_spread=", g_MaxSpread, " curr_spread=", localDouble_7);
        Sleep(7700);
        continue;
      }
      if (!(g_UseECNMode))
      {
        localInt_11 = OrderSend(param0_st, param1_in, localDouble_14, localDouble_4, g_MaxSlippage, param3_do, param4_do, comment + "_" + param6_st, param5_in, 0, localColor_2);
      }
      if (g_UseECNMode)
      {
        localInt_11 = OrderSend(param0_st, param1_in, localDouble_14, localDouble_4, g_MaxSlippage, 0.0, 0.0, comment + "_" + param6_st, param5_in, 0, localColor_2);
        tempin_17 = -1;
        tempin_18 = -1;
        tempst_19 = "";
        tempin_20 = localInt_11;
        tempin_21 = OrdersTotal();
        tempbo_24 = false;
        for (tempin_23 = 0; tempin_23 < tempin_21; tempin_23 = tempin_23 + 1)
        {
          if (!(OrderSelect(tempin_23, 0, 0)))
            continue;

          if ((OrderSymbol() != tempst_19 && tempst_19 != ""))
            continue;

          if ((tempin_18 >= 0 && OrderType() != tempin_18))
            continue;

          if ((tempin_17 >= 0 && OrderMagicNumber() != tempin_17) || OrderTicket() != tempin_20)
            continue;
          tempbo_24 = true;
          break;
        }
        if (tempbo_24)
        {
          ModifyOrder(-1.0, param3_do, param4_do, 0);
        }
      }
      if (localInt_11 > 0)
      {
        if (IsTesting())
          break;
        WindowScreenShot(WindowExpertName() + "\\" + string(param1_in) + WindowExpertName() + g_CurrentSymbol + string(Period()) + TimeCurrent() + "_.gif", 1024, 768, -1, -1, -1);
        break;
      }
      localInt_9 = GetLastError();
      Print("Error(", localInt_9, ") opening position: ", GetErrorDescription(localInt_9), ", try ", localInt_10);
      Print("Ask=", localDouble_5, " Bid=", localDouble_6, " sy=", param0_st, " lot=", localDouble_14, " op=", param1_in, " pp=", localDouble_4, " sl=", param3_do, " tp=", param4_do, " mn=", param5_in);
      if (localDouble_5 == 0.0 && localDouble_6 == 0.0)
      {
        Print("Проверьте в Обзоре рынка наличие символа " + param0_st);
      }
      Print("Ошибка " + string(localInt_9) + " Описание " + GetErrorDescription(localInt_9));
      if (localInt_9 == 2 || localInt_9 == 64 || localInt_9 == 65 || localInt_9 == 133)
        break;
      if ((localInt_9 == 128 || localInt_9 == 142 || localInt_9 == 143))
      {
        Sleep(66666);
      }
      if (localDouble_5 == 0.0 && localDouble_6 == 0.0)
      {
        Alert("Проверьте в Обзоре рынка наличие символа " + param0_st);
      }
      if (localInt_9 == 2 || localInt_9 == 64 || localInt_9 == 65 || localInt_9 == 133)
        break;
      if ((localInt_9 == 4 || localInt_9 == 131 || localInt_9 == 132))
      {
        Sleep(30000);
        break;
      }
      if (localInt_9 == 140 || localInt_9 == 148 || localInt_9 == 4110 || localInt_9 == 4111)
        break;
      if (localInt_9 == 141)
      {
        Sleep(100000);
      }
      if (localInt_9 == 145)
      {
        Sleep(17000);
      }
      if (localInt_9 == 146 && IsTradeContextBusy())
      {
        do
        {
          Sleep(500);
        } while (IsTradeContextBusy());
      }
      if (localInt_9 == 135)
        continue;
      Sleep(7700);
    }
    localDouble_15 = localDouble_15 + localDouble_14;
    if (!(g_UseLotLimit))
      break;
  }
  return (localInt_11);
}
// OpenPosition <<==--------   --------
double CalculateLotSize(double param0_do, bool param2_bo)
{
  double localDouble_1;
  string localString_2;
  string localString_3;
  double localDouble_4;
  double localDouble_5;
  double localDouble_6;
  double localDouble_7;
  int localInt_8;
  int localInt_9;
  int localInt_10;
  //----- -----
  bool tempbo_1;
  double tempdo_2;
  int tempin_3;
  int tempin_4;
  double tempdo_5;
  double tempdo_6;

  localString_2 = " Автор функции: ";
  localDouble_4 = 0.0;
  localDouble_5 = 0.0;
  localDouble_6 = 0.0;
  localDouble_7 = 0.0;
  localInt_8 = 0;
  localInt_10 = 0;
  localInt_9 = 0;
  if (MarketInfo(g_CurrentSymbol, 24) == 0.01)
  {
    localInt_8 = 2;
  }
  else
  {
    localInt_8 = 1;
  }
  localDouble_5 = MarketInfo(g_CurrentSymbol, 23);
  if (Lots < localDouble_5)
  {
    Lots = localDouble_5;
  }
  localDouble_6 = g_MaxLotSize;
  if (g_AutoMMFactor != 0.0)
  {
    if (fix_balance > 0.0)
    {
      localDouble_7 = fix_balance;
    }
    else
    {
      if (BaseForLotCalc == 0)
      {
        tempbo_1 = AccountEquity();
      }
      else
      {
        tempbo_1 = AccountBalance();
      }
      localDouble_7 = tempbo_1;
    }
    localDouble_7 = localDouble_7 + virtBalance;
    tempdo_2 = localDouble_7;
    tempin_3 = g_AutoMMFactor;
    tempin_4 = MarketInfo(g_CurrentSymbol, 16);
    tempdo_5 = 0.0;
    if (MarketInfo(g_CurrentSymbol, 11) != 0.0)
    {
      tempdo_5 = MarketInfo(g_CurrentSymbol, 9) / MarketInfo(g_CurrentSymbol, 11);
    }
    if (tempdo_5 * tempin_4 == 0.0)
    {
      PrintFormat(g_CurrentSymbol + " bidcorr*ValuePerPip==0");
      tempdo_6 = 0.0;
    }
    else
    {
      tempdo_6 = tempin_3 * tempdo_2 / (tempdo_5 * tempin_4);
    }
    localDouble_4 = tempdo_6 * g_DefaultLotSize;
  }
  else
  {
    if (FirstNumberp > 0 && LotsMartinp > 0.0)
    {
      localDouble_4 = Lots / MathPow(LotsMartinp, FirstNumberp);
    }
    else
    {
      localDouble_4 = Lots;
    }
  }
  if (param2_bo)
  {
    localDouble_4 = NormalizeDouble(localDouble_4, localInt_8);
  }
  return (localDouble_4);
}
// CalculateLotSize <<==--------   --------
void CloseOrdersByType(string param0_st, int param1_in, int param2_in)
{
  int localInt_1 = 0;
  int localInt_2;
  string localString_3;
  //----- -----
  int tempin_1;
  double tempdo_2;
  double tempdo_3;
  double tempdo_4;
  int tempin_5;
  string tempst_6;

  localInt_2 = OrdersTotal();
  localString_3 = " Автор функции:";
  if (param0_st == "0")
  {
    param0_st = g_CurrentSymbol;
  }
  for (localInt_1 = localInt_2 - 1; localInt_1 >= 0; localInt_1--)
  {
    if (!(OrderSelect(localInt_1, 0, 0)))
      continue;

    if ((OrderSymbol() != param0_st && param0_st != ""))
      continue;

    if ((param1_in >= 0 && OrderType() != param1_in))
      continue;

    if ((OrderType() != 0 && OrderType() != 1))
      continue;

    if ((param2_in >= 0 && OrderMagicNumber() != param2_in))
      continue;
    tempin_1 = 0;
    tempdo_2 = 0.0;
    tempdo_3 = 0.0;
    tempdo_4 = 0.0;
    tempin_5 = 0;
    if ((OrderType() != 0 && OrderType() != 1))
      continue;
    for (tempin_5 = 1; tempin_5 <= 20; tempin_5 = tempin_5 + 1)
    {
      RefreshRates();
      tempdo_2 = MarketInfo(OrderSymbol(), 10);
      tempdo_3 = MarketInfo(OrderSymbol(), 9);
      if (OrderType() == 0)
      {
        tempdo_4 = tempdo_3;
      }
      else
      {
        tempdo_4 = tempdo_2;
      }
      if (OrderClose(OrderTicket(), OrderLots(), tempdo_4, 1, tempin_1))
        break;
      Print("Error(", GetLastError(), ") opening position: ", GetErrorDescription(GetLastError()), ", try ", tempin_5);
      do
      {
        if ((GetLastError() != 146 || !(IsTradeContextBusy())))
          continue;
        Sleep(500);
      } while (IsTradeContextBusy());
    }
  }
}
// CloseOrdersByType <<==--------   --------
string GetErrorDescription(int param0_in)
{
  string localString_1;
  //----- -----

  switch (param0_in)
  {
  case 0:
  case 1:
    localString_1 = "no error";
    break;
  case 2:
    localString_1 = "common error";
    break;
  case 3:
    localString_1 = "invalid trade parameters";
    break;
  case 4:
    localString_1 = "trade server is busy";
    break;
  case 5:
    localString_1 = "old version of the client terminal";
    break;
  case 6:
    localString_1 = "no connection with trade server";
    break;
  case 7:
    localString_1 = "not enough rights";
    break;
  case 8:
    localString_1 = "too frequent requests";
    break;
  case 9:
    localString_1 = "malfunctional trade operation (never returned error)";
    break;
  case 64:
    localString_1 = "account disabled";
    break;
  case 65:
    localString_1 = "invalid account";
    break;
  case 128:
    localString_1 = "trade timeout";
    break;
  case 129:
    localString_1 = "invalid price";
    break;
  case 130:
    localString_1 = "invalid stops";
    break;
  case 131:
    localString_1 = "invalid trade volume";
    break;
  case 132:
    localString_1 = "market is closed";
    break;
  case 133:
    localString_1 = "trade is disabled";
    break;
  case 134:
    localString_1 = "not enough money";
    break;
  case 135:
    localString_1 = "price changed";
    break;
  case 136:
    localString_1 = "off quotes";
    break;
  case 137:
    localString_1 = "broker is busy (never returned error)";
    break;
  case 138:
    localString_1 = "requote";
    break;
  case 139:
    localString_1 = "order is locked";
    break;
  case 140:
    localString_1 = "long positions only allowed";
    break;
  case 141:
    localString_1 = "too many requests";
    break;
  case 145:
    localString_1 = "modification denied because order too close to market";
    break;
  case 146:
    localString_1 = "trade context is busy";
    break;
  case 147:
    localString_1 = "expirations are denied by broker";
    break;
  case 148:
    localString_1 = "amount of open and pending orders has reached the limit";
    break;
  case 149:
    localString_1 = "hedging is prohibited";
    break;
  case 150:
    localString_1 = "prohibited by FIFO rules";
    break;
  case 4000:
    localString_1 = "no error (never generated code)";
    break;
  case 4001:
    localString_1 = "wrong function pointer";
    break;
  case 4002:
    localString_1 = "array index is out of range";
    break;
  case 4003:
    localString_1 = "no memory for function call stack";
    break;
  case 4004:
    localString_1 = "recursive stack overflow";
    break;
  case 4005:
    localString_1 = "not enough stack for parameter";
    break;
  case 4006:
    localString_1 = "no memory for parameter string";
    break;
  case 4007:
    localString_1 = "no memory for temp string";
    break;
  case 4008:
    localString_1 = "not initialized string";
    break;
  case 4009:
    localString_1 = "not initialized string in array";
    break;
  case 4010:
    localString_1 = "no memory for array\' string";
    break;
  case 4011:
    localString_1 = "too long string";
    break;
  case 4012:
    localString_1 = "remainder from zero divide";
    break;
  case 4013:
    localString_1 = "zero divide";
    break;
  case 4014:
    localString_1 = "unknown command";
    break;
  case 4015:
    localString_1 = "wrong jump (never generated error)";
    break;
  case 4016:
    localString_1 = "not initialized array";
    break;
  case 4017:
    localString_1 = "dll calls are not allowed";
    break;
  case 4018:
    localString_1 = "cannot load library";
    break;
  case 4019:
    localString_1 = "cannot call function";
    break;
  case 4020:
    localString_1 = "expert function calls are not allowed";
    break;
  case 4021:
    localString_1 = "not enough memory for temp string returned from function";
    break;
  case 4022:
    localString_1 = "system is busy (never generated error)";
    break;
  case 4050:
    localString_1 = "invalid function parameters count";
    break;
  case 4051:
    localString_1 = "invalid function parameter value";
    break;
  case 4052:
    localString_1 = "string function internal error";
    break;
  case 4053:
    localString_1 = "some array error";
    break;
  case 4054:
    localString_1 = "incorrect series array using";
    break;
  case 4055:
    localString_1 = "custom indicator error";
    break;
  case 4056:
    localString_1 = "arrays are incompatible";
    break;
  case 4057:
    localString_1 = "global variables processing error";
    break;
  case 4058:
    localString_1 = "global variable not found";
    break;
  case 4059:
    localString_1 = "function is not allowed in testing mode";
    break;
  case 4060:
    localString_1 = "function is not confirmed";
    break;
  case 4061:
    localString_1 = "send mail error";
    break;
  case 4062:
    localString_1 = "string parameter expected";
    break;
  case 4063:
    localString_1 = "integer parameter expected";
    break;
  case 4064:
    localString_1 = "double parameter expected";
    break;
  case 4065:
    localString_1 = "array as parameter expected";
    break;
  case 4066:
    localString_1 = "requested history data in update state";
    break;
  case 4099:
    localString_1 = "end of file";
    break;
  case 4100:
    localString_1 = "some file error";
    break;
  case 4101:
    localString_1 = "wrong file name";
    break;
  case 4102:
    localString_1 = "too many opened files";
    break;
  case 4103:
    localString_1 = "cannot open file";
    break;
  case 4104:
    localString_1 = "incompatible access to a file";
    break;
  case 4105:
    localString_1 = "no order selected";
    break;
  case 4106:
    localString_1 = "unknown symbol";
    break;
  case 4107:
    localString_1 = "invalid price parameter for trade function";
    break;
  case 4108:
    localString_1 = "invalid ticket";
    break;
  case 4109:
    localString_1 = "trade is not allowed in the expert properties";
    break;
  case 4110:
    localString_1 = "longs are not allowed in the expert properties";
    break;
  case 4111:
    localString_1 = "shorts are not allowed in the expert properties";
    break;
  case 4200:
    localString_1 = "object is already exist";
    break;
  case 4201:
    localString_1 = "unknown object property";
    break;
  case 4202:
    localString_1 = "object is not exist";
    break;
  case 4203:
    localString_1 = "unknown object type";
    break;
  case 4204:
    localString_1 = "no object name";
    break;
  case 4205:
    localString_1 = "object coordinates error";
    break;
  case 4206:
    localString_1 = "no specified subwindow";
    break;
  default:
    localString_1 = "unknown error";
  }
  return (localString_1);
}
// GetErrorDescription <<==--------   --------
int ManageAddPosition()
{
  int localInt_1;
  double localDouble_2;
  bool localBool_3;
  int localInt_4;
  int localInt_5;
  int localInt_6;

  if (!(CheckOrderExists(g_CurrentSymbol, -1, g_CurrentMagic, 0, "")))
  {
    if (!(IsFirstPositionAllowed()))
    {
      g_CurrentLevel = 0;
      GlobalVariableSet(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic), 0.0);
      GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + string(g_InternalMagic) + "peak", 0.0);
      ObjectDelete(0, g_CurrentMagic);
    }
  }
  if (!(CheckOrderExists(g_CurrentSymbol, -1, g_CurrentMagic, 0, "")))
  {
    if (IsFirstPositionAllowed())
    {
      if ((CheckHolidayRestriction() != "" || FirstPositionp == 4))
      {
        GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "0" + string(g_InternalMagic), 0.0);
        GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "1" + string(g_InternalMagic), 0.0);
        g_CurrentLevel = 0;
        GlobalVariableSet(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic), 0.0);
        GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + string(g_InternalMagic) + "peak", 0.0);
        ObjectDelete(0, g_CurrentMagic);
      }
    }
  }
  if (g_NextEntryPrice == 0.0)
  {
    if (CheckOrderExists(g_CurrentSymbol, 0, g_CurrentMagic, 0, ""))
    {
      g_GridDistancePoints = (g_MinPrice - g_MaxPrice) / g_PointValue;
      g_NextEntryPrice = (g_TickValue - g_GridDistancePoints) * g_PointValue + MathMin(iClose(g_CurrentSymbol, 0, 1), g_SwapShort);
      GlobalVariableSet(string(IsTesting()) + "Distance_Price" + g_CurrentSymbol + string(g_InternalMagic), g_NextEntryPrice);
      UpdateGridDistance();
    }
    if (CheckOrderExists(g_CurrentSymbol, 1, g_CurrentMagic, 0, ""))
    {
      g_GridDistancePoints = (g_MinPrice - g_MaxPrice) / g_PointValue;
      g_NextEntryPrice = g_GridDistancePoints * g_PointValue + MathMax(iClose(g_CurrentSymbol, 0, 1), g_SwapShort);
      GlobalVariableSet(string(IsTesting()) + "Distance_Price" + g_CurrentSymbol + string(g_InternalMagic), g_NextEntryPrice);
      UpdateGridDistance();
    }
  }
  if (!(GlobalVariableCheck(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic))))
  {
    SetNUMBER(g_CurrentSymbol, -1, g_CurrentMagic);
  }
  localDouble_2 = 0.0;
  localBool_3 = false;
  localInt_5 = 0;
  localInt_4 = 0;
  g_TickValue = MarketInfo(g_CurrentSymbol, 13);
  g_SpreadValue = MarketInfo(g_CurrentSymbol, 13) * MarketInfo(g_CurrentSymbol, 11);
  g_SwapLong = MarketInfo(g_CurrentSymbol, 10);
  g_SwapShort = MarketInfo(g_CurrentSymbol, 9);
  g_PointValue = MarketInfo(g_CurrentSymbol, 11);
  g_MarginRequired = 0.0;
  if (iClose(g_CurrentSymbol, 0, 1) > 0.0)
  {
    g_MarginRequired = (MathAbs(g_SwapShort / iClose(g_CurrentSymbol, 0, 1) - 1.0)) * 10000.0;
  }
  localInt_6 = 0;
  if (g_NextEntryPrice != 0.0)
  {
    if (DELAYtime(g_CurrentSymbol, -1, g_CurrentMagic, "HS", iTime(g_CurrentSymbol, 0, 0)) > g_MaxRetries * g_Reserved1 * PeriodSeconds(0) && g_MarginRequired < 20.0)
    {
      if ((CheckOrderExists(g_CurrentSymbol, 0, g_CurrentMagic, 0, "") || CheckDrawdownLimit(0)))
      {
        if (g_SwapLong <= g_NextEntryPrice)
        {
          localBool_3 = false;
          localDouble_2 = NormalizeDouble(CalculateLotSize(1.0, false) * MathPow(g_MartinMultiplier, MathMin(g_RecoveryLossPercent, g_CurrentLevel + 1)), 2);
          if ((FirstNumberp > g_CurrentLevel + 1 || (g_RecoveryProfitPercent < g_CurrentLevel + 1 && g_RecoveryProfitPercent > 0)))
          {
            localBool_3 = true;
            localInt_6 = -1;
            Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " The opened grid level is less than the minimum level. The deal is virtualized");
          }
          else
          {
            if (localDouble_2 < 0.01)
            {
              localBool_3 = true;
              localInt_6 = -1;
              Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " Current lot <0.01. The average deal is virtualized");
            }
            else
            {
              if (!(CheckOrderExists(g_CurrentSymbol, 0, g_CurrentMagic, 0, "")) && MaxOtherMagics > 0)
              {
                if (CountOtherMagics(g_CurrentMagic, "") >= MaxOtherMagics)
                {
                  localBool_3 = true;
                  localInt_6 = -1;
                  Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " GetOtherMagicsCount >= MaxOtherMagics. The deal is virtualized");
                  if (FirstNumberp <= g_CurrentLevel + 1)
                  {
                    g_CurrentLevel--;
                  }
                }
              }
              else
              {
                if (!(CheckOrderExists(g_CurrentSymbol, 0, g_CurrentMagic, 0, "")) && MaxOtherSymbols > 0)
                {
                  if (CountOtherSymbols(g_CurrentSymbol) >= MaxOtherSymbols)
                  {
                    localBool_3 = true;
                    localInt_6 = -1;
                    Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " GetOtherSymbolsCount >= MaxOtherSymbols. The deal is virtualized");
                    if (FirstNumberp <= g_CurrentLevel + 1)
                    {
                      g_CurrentLevel--;
                    }
                  }
                }
                else
                {
                  localInt_6 = OpenPosition(g_CurrentSymbol, 0, localDouble_2, 0.0, 0.0, g_CurrentMagic, "C" + IntegerToString(g_CurrentLevel + 1, 0, 32), g_NextEntryPrice);
                  if (localInt_6 > 0)
                  {
                    GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "0" + string(g_InternalMagic), 0.0);
                    localBool_3 = true;
                  }
                }
              }
            }
          }
          if (localBool_3)
          {
            g_CurrentLevel++;
            lizong80(localInt_6);
            GlobalVariableSet(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic), g_CurrentLevel);
            g_GridDistancePoints = (g_MinPrice - g_MaxPrice) / g_PointValue;
            g_NextEntryPrice = MathMin(iClose(g_CurrentSymbol, 0, 1), g_SwapShort) + (g_TickValue - g_GridDistancePoints) * g_PointValue;
            GlobalVariableSet(string(IsTesting()) + "Distance_Price" + g_CurrentSymbol + string(g_InternalMagic), g_NextEntryPrice);
            UpdateGridDistance();
          }
        }
      }
      else
      {
        if ((CheckOrderExists(g_CurrentSymbol, 1, g_CurrentMagic, 0, "") || CheckDrawdownLimit(1)) && g_SwapShort >= g_NextEntryPrice)
        {
          localBool_3 = false;
          localDouble_2 = NormalizeDouble(CalculateLotSize(1.0, false) * MathPow(g_MartinMultiplier, MathMin(g_RecoveryLossPercent, g_CurrentLevel + 1)), 2);
          if ((FirstNumberp > g_CurrentLevel + 1 || (g_RecoveryProfitPercent < g_CurrentLevel + 1 && g_RecoveryProfitPercent > 0)))
          {
            localBool_3 = true;
            localInt_6 = -1;
            Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " The opened grid level is less than the minimum level. The deal is virtualized");
          }
          else
          {
            if (localDouble_2 < 0.01)
            {
              localBool_3 = true;
              localInt_6 = -1;
              Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " Current lot <0.01. The average deal is virtualized");
            }
            else
            {
              if (!(CheckOrderExists(g_CurrentSymbol, 1, g_CurrentMagic, 0, "")) && MaxOtherMagics > 0)
              {
                if (CountOtherMagics(g_CurrentMagic, "") >= MaxOtherMagics)
                {
                  localBool_3 = true;
                  localInt_6 = -1;
                  Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " GetOtherMagicsCount >= MaxOtherMagics. The deal is virtualized");
                  if (FirstNumberp <= g_CurrentLevel + 1)
                  {
                    g_CurrentLevel--;
                  }
                }
              }
              else
              {
                if (!(CheckOrderExists(g_CurrentSymbol, 1, g_CurrentMagic, 0, "")) && MaxOtherSymbols > 0)
                {
                  if (CountOtherSymbols(g_CurrentSymbol) >= MaxOtherSymbols)
                  {
                    localBool_3 = true;
                    localInt_6 = -1;
                    Print(g_CurrentSymbol + " " + string(g_CurrentMagic) + " GetOtherSymbolsCount >= MaxOtherSymbols. The deal is virtualized");
                    if (FirstNumberp <= g_CurrentLevel + 1)
                    {
                      g_CurrentLevel--;
                    }
                  }
                }
                else
                {
                  localInt_6 = OpenPosition(g_CurrentSymbol, 1, localDouble_2, 0.0, 0.0, g_CurrentMagic, "C" + IntegerToString(g_CurrentLevel + 1, 0, 32), g_NextEntryPrice);
                  if (localInt_6 > 0)
                  {
                    GlobalVariableSet(string(IsTesting()) + g_CurrentSymbol + "1" + string(g_InternalMagic), 0.0);
                    localBool_3 = true;
                  }
                }
              }
            }
          }
          if (localBool_3)
          {
            g_CurrentLevel++;
            lizong80(localInt_6);
            GlobalVariableSet(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic), g_CurrentLevel);
            g_GridDistancePoints = (g_MinPrice - g_MaxPrice) / g_PointValue;
            g_NextEntryPrice = g_GridDistancePoints * g_PointValue + MathMax(iClose(g_CurrentSymbol, 0, 1), g_SwapShort);
            GlobalVariableSet(string(IsTesting()) + "Distance_Price" + g_CurrentSymbol + string(g_InternalMagic), g_NextEntryPrice);
            UpdateGridDistance();
          }
        }
      }
    }
  }
  return (0);
}
// ManageAddPosition <<==--------   --------
string CurrencyToIndex(string param0_st)
{
  string tempst_1;

  if (StringLen(param0_st) != 3)
  {
    tempst_1 = "9";
    return (tempst_1);
  }
  if (param0_st == "AUD")
  {
    tempst_1 = "1";
    return (tempst_1);
  }
  if (param0_st == "CAD")
  {
    tempst_1 = "2";
    return (tempst_1);
  }
  if (param0_st == "EUR")
  {
    tempst_1 = "3";
    return (tempst_1);
  }
  if (param0_st == "GBP")
  {
    tempst_1 = "4";
    return (tempst_1);
  }
  if (param0_st == "JPY")
  {
    tempst_1 = "5";
    return (tempst_1);
  }
  if (param0_st == "NZD")
  {
    tempst_1 = "6";
    return (tempst_1);
  }
  if (param0_st == "USD")
  {
    tempst_1 = "7";
    return (tempst_1);
  }
  tempst_1 = "9";
  return (tempst_1);
}
// CurrencyToIndex <<==--------   --------
int GetOrdersProfit()
{
  int localInt_1;
  string localString_2;
  string localString_3;
  string localString_4;
  string localString_5;
  string localString_6;
  string localString_7;
  string localString_8;
  string localString_9;
  int localInt_10;
  string localString_11;
  int localInt_12;
  int localInt_13;
  int localInt_14;
  //----- -----
  int tempin_1;
  int tempin_2;
  string tempst_3;
  string tempst_4;
  int tempin_5;
  string tempst_6;
  string tempst_7;
  string tempst_8;
  string tempst_9;

  localString_2 = "";
  localString_3 = "";
  localString_4 = "";
  localString_5 = "";
  localString_6 = "";
  localString_7 = "";
  localString_8 = "";
  localString_9 = "";
  localInt_10 = 0;
  localString_11 = MQLInfoString(MQL_PROGRAM_NAME) + " orders " + g_CurrentSymbol + " " + string(g_TotalAdvisors) + "-" + string(g_Reserved1) + "-" + string(g_MinPipStep) + "-" + string(g_MaxPipStep) + "-" + string(g_TakeProfit1) + "-" + string(g_TakeProfit2) + "-" + string(g_TakeProfitPips) + "-" + string(g_StopLossMultiplier) + ".csv";
  FileDelete(StringConcatenate("Report ", AccountNumber()) + "//" + localString_11, 0);
  localInt_12 = FileOpen(StringConcatenate("Report ", AccountNumber()) + "//" + localString_11, 11);
  if (localInt_12 == -1)
  {
    PrintFormat("ошибка открытия файла");
  }
  if (localInt_12 != -1)
  {
    FileWrite(localInt_12, "Прогон", "Ордер Тиккет", "Тип ордера", "Лоты", "Пара", "Цена открытия", "Цена закрытия", "Stop loss", "Take profot", "Время открытия", "Время закрытия", "Меджик номер", "Профит", "Своп", "Комиссии", "Коммент", "Аналитика");
    FileSeek(localInt_12, 0, 2);
    localInt_13 = 0;
    for (localInt_14 = 0; localInt_14 < HistoryTotal(); localInt_14++)
    {
      if (OrderSelect(localInt_14, 0, 1))
      {
        localInt_10 = MarketInfo(OrderSymbol(), 12);
        localString_2 = DoubleToString(OrderProfit(), 2);
        localString_3 = DoubleToString(OrderSwap(), 2);
        localString_4 = DoubleToString(OrderCommission(), 2);
        localString_5 = DoubleToString(OrderLots(), 2);
        localString_6 = DoubleToString(OrderOpenPrice(), localInt_10);
        localString_7 = DoubleToString(OrderClosePrice(), localInt_10);
        localString_8 = DoubleToString(OrderStopLoss(), localInt_10);
        localString_9 = DoubleToString(OrderTakeProfit(), localInt_10);
        tempin_1 = OrderTicket();
        for (tempin_2 = 0; tempin_2 < 40000; tempin_2 = tempin_2 + 1)
        {
          if (g_OrderTicketArray[tempin_2] != tempin_1)
            continue;
          tempst_3 = g_OrderCommentArray[tempin_2];
          break;
        }
        tempst_3 = "0";
        tempst_4 = OrderComment();
        tempin_5 = OrderMagicNumber();
        tempst_6 = TimeToString(OrderCloseTime(), 3);
        tempst_7 = TimeToString(OrderOpenTime(), 3);
        tempst_8 = OrderSymbol();
        tempst_9 = "";
        switch (OrderType())
        {
        case 0:
          tempst_9 = "BUY";
          break;
        case 1:
          tempst_9 = "SELL";
          break;
        case 2:
          tempst_9 = "BUY LIMIT";
          break;
        case 3:
          tempst_9 = "SELL LIMIT";
          break;
        case 4:
          tempst_9 = "BUY STOP";
          break;
        case 5:
          tempst_9 = "SELL STOP";
          break;
        case 6:
          tempst_9 = "DEPOSIT";
        }
        FileWrite(localInt_12, MQLInfoString(MQL_PROGRAM_NAME) + " orders " + string(g_TotalAdvisors) + "-" + string(g_Reserved1) + "-" + string(g_MinPipStep) + "-" + string(g_MaxPipStep) + "-" + string(g_TakeProfit1) + "-" + string(g_TakeProfit2) + "-" + string(g_TakeProfitPips) + "-" + string(g_StopLossMultiplier) + ".csv", DoubleToString(OrderTicket(), 0), tempst_9, localString_5, tempst_8, localString_6, localString_7, localString_8, localString_9, tempst_7, tempst_6, tempin_5, localString_2, localString_3, localString_4, tempst_4, tempst_3);
      }
    }
    FileClose(localInt_12);
  }
  return (0);
}
// GetOrdersProfit <<==--------   --------
int GetOrdersCount()
{
  int localInt_1;
  int localInt_2;
  int localInt_3;
  string localString_4;
  string localString_5;
  string localString_6;
  string localString_7;
  int localInt_8;
  string localString_9;
  int localInt_10;
  int localInt_11;
  //----- -----

  localInt_2 = -1;
  localInt_3 = -1;
  localString_4 = "";
  localString_5 = "";
  localString_6 = "";
  localString_7 = "";
  localInt_8 = 0;
  localString_9 = MQLInfoString(MQL_PROGRAM_NAME) + " equity " + g_CurrentSymbol + " " + string(g_TotalAdvisors) + "-" + string(g_Reserved1) + "-" + string(g_MinPipStep) + "-" + string(g_MaxPipStep) + "-" + string(g_TakeProfit1) + "-" + string(g_TakeProfit2) + "-" + string(g_TakeProfitPips) + "-" + string(g_StopLossMultiplier) + ".csv";
  FileDelete(StringConcatenate("Report ", AccountNumber()) + "//" + localString_9, 0);
  localInt_10 = FileOpen(StringConcatenate("Report ", AccountNumber()) + "//" + localString_9, 11);
  if (localInt_10 == -1)
  {
    PrintFormat("ошибка открытия файла");
  }
  if (localInt_10 != -1)
  {
    FileWrite(localInt_10, "прогон", "пара", "дата", "balance", "equity", "min_equity", "symbol_koef", "margin", "max_margin");
    FileSeek(localInt_10, 0, 2);
    for (localInt_11 = 0; localInt_11 < g_LastProcessedOrder; localInt_11++)
    {
      FileWrite(localInt_10, MQLInfoString(MQL_PROGRAM_NAME) + " equity " + string(g_TotalAdvisors) + "-" + string(g_Reserved1) + "-" + string(g_MinPipStep) + "-" + string(g_MaxPipStep) + "-" + string(g_TakeProfit1) + "-" + string(g_TakeProfit2) + "-" + string(g_TakeProfitPips) + "-" + string(g_StopLossMultiplier) + ".csv", g_CurrentSymbol, TimeToString(int(g_OrderProfitArray[0][localInt_11]), 3), int(g_OrderProfitArray[1][localInt_11]), int(g_OrderProfitArray[2][localInt_11]), int(g_OrderProfitArray[3][localInt_11]), int(g_OrderProfitArray[5][localInt_11]), int(g_OrderProfitArray[6][localInt_11]));
    }
    FileClose(localInt_10);
  }
  return (0);
}
// GetOrdersCount <<==--------   --------
void ParseSettingsString(string settingsStr, _sets &settingsArray[])
{
  string setStrings[];         // Each set string, split by ';'
  string paramPairs[];         // Each param pair, split by ','
  string keyValue[];           // Each key-value, split by '='
  double defaultReserved1;
  double defaultStopLossMultiplier;
  double defaultTakeProfitPips;
  double defaultTakeProfit2;
  double defaultTakeProfit1;
  double defaultLotMultiplier;
  int defaultMinPipStep;
  string defaultSetName;
  //----- -----
  int numSets;
  int setIdx;
  int paramIdx;
  int numParams;
  int paramPairIdx;
  int keyValueIdx;
  int numKeyValues;
  int maxSets = 9;
  int maxLoop = 7318875;

  defaultSetName = "base";
  defaultMinPipStep = g_MinPipStep;
  defaultLotMultiplier = g_LotMultiplier;
  defaultTakeProfit1 = g_TakeProfit1;
  defaultTakeProfit2 = g_TakeProfit2;
  defaultTakeProfitPips = g_TakeProfitPips;
  defaultStopLossMultiplier = g_StopLossMultiplier;
  defaultReserved1 = g_Reserved1;
  StringSplit(settingsStr, StringGetCharacter(";", 0), setStrings);
  numSets = ArraySize(setStrings);
  for (setIdx = 0; setIdx < numSets; setIdx++)
  {
    setStrings[setIdx] = StringTrimLeft(StringTrimRight(setStrings[setIdx]));
  }
  paramIdx = 0;
  numParams = ArrayRange(setStrings, 0);
  while (paramIdx < MathMin(maxLoop, maxSets))
  {
    if (StringTrimLeft(StringTrimRight(setStrings[paramIdx])) != "")
    {
      ArrayResize(settingsArray, paramIdx + 1, 0);
      settingsArray[paramIdx].setName = defaultSetName;
      settingsArray[paramIdx].magicNumber = defaultSetName;
      settingsArray[paramIdx].martinMultiplier = defaultSetName;
      settingsArray[paramIdx].minProfitPercent = defaultSetName;
      settingsArray[paramIdx].maxDrawdownPercent = defaultSetName;
      settingsArray[paramIdx].riskPercent = defaultSetName;
      settingsArray[paramIdx].tpMultiplier = defaultSetName;
      settingsArray[paramIdx].reserved = defaultSetName;
      int printSetNum = paramIdx + 1;
      PrintFormat("using set #" + IntegerToString(printSetNum, 0, 32) + ": " + setStrings[paramIdx]);
      StringSplit(setStrings[paramIdx], StringGetCharacter(",", 0), paramPairs);
      int numParamPairs = ArraySize(paramPairs);
      for (paramPairIdx = 0; paramPairIdx < numParamPairs; paramPairIdx++)
      {
        paramPairs[paramPairIdx] = StringTrimLeft(StringTrimRight(paramPairs[paramPairIdx]));
      }
      for (paramIdx = 0; paramIdx < ArrayRange(paramPairs, 0); paramIdx = paramIdx + 1)
      {
        StringSplit(paramPairs[paramIdx], StringGetCharacter("=", 0), keyValue);
        numKeyValues = ArraySize(keyValue);
        for (keyValueIdx = 0; keyValueIdx < numKeyValues; keyValueIdx++)
        {
          keyValue[keyValueIdx] = StringTrimLeft(StringTrimRight(keyValue[keyValueIdx]));
        }
        if (keyValue[0] == "s1")
        {
          settingsArray[paramIdx].setName = keyValue[1];
        }
        else if (keyValue[0] == "s2")
        {
          settingsArray[paramIdx].magicNumber = StringToInteger(keyValue[1]);
        }
        else if (keyValue[0] == "s3")
        {
          settingsArray[paramIdx].martinMultiplier = StringToDouble(keyValue[1]);
        }
        else if (keyValue[0] == "s4")
        {
          settingsArray[paramIdx].minProfitPercent = StringToDouble(keyValue[1]);
        }
        else if (keyValue[0] == "s5")
        {
          settingsArray[paramIdx].maxDrawdownPercent = StringToDouble(keyValue[1]);
        }
        else if (keyValue[0] == "s6")
        {
          settingsArray[paramIdx].riskPercent = StringToDouble(keyValue[1]);
        }
        else if (keyValue[0] == "s7")
        {
          settingsArray[paramIdx].tpMultiplier = StringToDouble(keyValue[1]);
        }
        else if (keyValue[0] == "s8")
        {
          settingsArray[paramIdx].reserved = StringToDouble(keyValue[1]);
        }
      }
    }
    paramIdx = paramIdx + 1;
    maxLoop = ArrayRange(setStrings, 0);
  }
}
// ParseSettingsString <<==--------   --------
void InitializeArrays()
{
  g_PriceGridArray[0][0][0] = 0.0000897;
  g_PriceGridArray[0][1][0] = 0.0001034;
  g_PriceGridArray[0][2][0] = 0.0001795;
  g_PriceGridArray[0][3][0] = 0.0002647;
  g_PriceGridArray[0][4][0] = 0.0002584;
  g_PriceGridArray[1][0][0] = 0.0000588;
  g_PriceGridArray[1][1][0] = 0.0000813;
  g_PriceGridArray[1][2][0] = 0.0001579;
  g_PriceGridArray[1][3][0] = 0.0003007;
  g_PriceGridArray[1][4][0] = 0.0004076;
  g_PriceGridArray[2][0][0] = 0.0000738;
  g_PriceGridArray[2][1][0] = 0.0000939;
  g_PriceGridArray[2][2][0] = 0.0001887;
  g_PriceGridArray[2][3][0] = 0.0003237;
  g_PriceGridArray[2][4][0] = 0.0003535;
  g_PriceGridArray[3][0][0] = 0.0000645;
  g_PriceGridArray[3][1][0] = 0.0000914;
  g_PriceGridArray[3][2][0] = 0.000148;
  g_PriceGridArray[3][3][0] = 0.0002208;
  g_PriceGridArray[3][4][0] = 0.00025;
  g_PriceGridArray[4][0][0] = 0.000054;
  g_PriceGridArray[4][1][0] = 0.0000639;
  g_PriceGridArray[4][2][0] = 0.0000964;
  g_PriceGridArray[4][3][0] = 0.0001486;
  g_PriceGridArray[4][4][0] = 0.0001765;
  g_PriceGridArray[5][0][0] = 0.000258;
  g_PriceGridArray[5][1][0] = 0.000221;
  g_PriceGridArray[5][2][0] = 0.000159;
  g_PriceGridArray[5][3][0] = 0.000221;
  g_PriceGridArray[5][4][0] = 0.000258;
  g_PriceGridArray[0][0][1] = 0.5292458;
  g_PriceGridArray[0][1][1] = 0.5154581;
  g_PriceGridArray[0][2][1] = 0.4603964;
  g_PriceGridArray[0][3][1] = 0.4371622;
  g_PriceGridArray[0][4][1] = 0.4761835;
  g_PriceGridArray[1][0][1] = 0.5749035;
  g_PriceGridArray[1][1][1] = 0.5317178;
  g_PriceGridArray[1][2][1] = 0.4514056;
  g_PriceGridArray[1][3][1] = 0.3911576;
  g_PriceGridArray[1][4][1] = 0.3704194;
  g_PriceGridArray[2][0][1] = 0.5909246;
  g_PriceGridArray[2][1][1] = 0.5569647;
  g_PriceGridArray[2][2][1] = 0.475178;
  g_PriceGridArray[2][3][1] = 0.4380521;
  g_PriceGridArray[2][4][1] = 0.4670035;
  g_PriceGridArray[3][0][1] = 0.5916496;
  g_PriceGridArray[3][1][1] = 0.5410278;
  g_PriceGridArray[3][2][1] = 0.4918849;
  g_PriceGridArray[3][3][1] = 0.461836;
  g_PriceGridArray[3][4][1] = 0.49;
  g_PriceGridArray[4][0][1] = 0.5956147;
  g_PriceGridArray[4][1][1] = 0.5731626;
  g_PriceGridArray[4][2][1] = 0.538971;
  g_PriceGridArray[4][3][1] = 0.513383;
  g_PriceGridArray[4][4][1] = 0.5309254;
  g_PriceGridArray[5][0][1] = 0.476184;
  g_PriceGridArray[5][1][1] = 0.461836;
  g_PriceGridArray[5][2][1] = 0.479234;
  g_PriceGridArray[5][3][1] = 0.461836;
  g_PriceGridArray[5][4][1] = 0.476184;
}
// InitializeArrays <<==--------   --------
bool CreateGraphicObject(long param0_lo, string param1_st, int param2_in, int param3_in, int param4_in, int param5_in, int param6_in, int param7_in, int param8_in, int param9_in, int param10_in, int param11_in, int param12_in, char param13_ch, char param14_ch, char param15_ch, long param16_lo)
{
  bool localBool_1;
  //----- -----

  ResetLastError();
  if (ObjectFind(param0_lo, param1_st) >= 0)
  {
    ObjectDelete(param0_lo, param1_st);
  }
  if (!(ObjectCreate(param0_lo, param1_st, 28, param2_in, 0, 0.0)))
  {
    Print("RectLabelCreate", ": не удалось создать прямоугольную метку! Код ошибки = ", GetLastError());
    return (false);
  }
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_XDISTANCE, param3_in);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_YDISTANCE, param4_in);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_XSIZE, param5_in);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_YSIZE, param6_in);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_BGCOLOR, param7_in);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_BORDER_TYPE, param8_in);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_CORNER, param9_in);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_COLOR, param10_in);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_STYLE, param11_in);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_WIDTH, param12_in);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_BACK, param13_ch);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_SELECTABLE, param14_ch);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_SELECTED, param14_ch);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_HIDDEN, param15_ch);
  ObjectSetInteger(param0_lo, param1_st, OBJPROP_ZORDER, param16_lo);
  return (true);
}
// CreateGraphicObject <<==--------   --------
void CreateDashboardPanel()
{
  int localInt_1;
  int localInt_2;
  int localInt_3;
  int localInt_4;
  int localInt_5;
  int localInt_6;
  string localString_7;
  string localString_8;
  //----- -----
  string tempst_1;
  string tempst_2;
  int tempin_3;
  int tempin_4;
  int tempin_5;
  int tempin_6;
  string tempst_7;
  int tempin_8;
  int tempin_9;
  int tempin_10;
  int tempin_11;
  int tempin_12;
  string tempst_13;
  int tempin_14;
  int tempin_15;
  int tempin_16;
  int tempin_17;
  int tempin_18;
  string tempst_19;
  int tempin_20;
  int tempin_21;
  int tempin_22;
  int tempin_23;
  int tempin_24;
  string tempst_25;
  int tempin_26;
  int tempin_27;
  int tempin_28;
  int tempin_29;
  int tempin_30;
  string tempst_31;
  int tempin_32;
  int tempin_33;
  int tempin_34;
  int tempin_35;
  int tempin_36;
  string tempst_37;
  int tempin_38;
  int tempin_39;
  int tempin_40;
  int tempin_41;
  int tempin_42;
  string tempst_43;
  int tempin_44;
  int tempin_45;
  int tempin_46;
  int tempin_47;
  int tempin_48;
  string tempst_49;
  int tempin_50;
  int tempin_51;
  int tempin_52;
  int tempin_53;
  int tempin_54;
  string tempst_55;
  int tempin_56;
  int tempin_57;
  int tempin_58;
  int tempin_59;
  int tempin_60;
  string tempst_61;
  int tempin_62;
  int tempin_63;
  int tempin_64;
  int tempin_65;
  int tempin_66;
  string tempst_67;
  int tempin_68;
  int tempin_69;
  int tempin_70;
  int tempin_71;
  int tempin_72;
  string tempst_73;
  int tempin_74;
  int tempin_75;
  int tempin_76;
  int tempin_77;
  int tempin_78;
  string tempst_79;
  int tempin_80;
  int tempin_81;
  int tempin_82;
  int tempin_83;
  int tempin_84;
  string tempst_85;
  int tempin_86;
  int tempin_87;
  int tempin_88;
  int tempin_89;
  int tempin_90;
  string tempst_91;
  int tempin_92;
  int tempin_93;
  int tempin_94;
  int tempin_95;
  int tempin_96;
  string tempst_97;
  int tempin_98;
  int tempin_99;
  int tempin_100;
  int tempin_101;
  int tempin_102;
  string tempst_103;
  int tempin_104;
  int tempin_105;
  int tempin_106;
  int tempin_107;
  int tempin_108;
  string tempst_109;
  int tempin_110;
  int tempin_111;
  int tempin_112;
  int tempin_113;
  int tempin_114;
  string tempst_115;
  int tempin_116;
  int tempin_117;
  int tempin_118;
  int tempin_119;
  int tempin_120;
  string tempst_121;
  int tempin_122;
  int tempin_123;
  int tempin_124;
  int tempin_125;
  int tempin_126;
  string tempst_127;
  int tempin_128;
  int tempin_129;
  int tempin_130;
  int tempin_131;
  int tempin_132;
  string tempst_133;
  int tempin_134;
  int tempin_135;
  int tempin_136;
  int tempin_137;
  int tempin_138;
  string tempst_139;
  int tempin_140;
  int tempin_141;
  int tempin_142;
  int tempin_143;
  int tempin_144;
  string tempst_145;
  int tempin_146;
  int tempin_147;
  int tempin_148;
  int tempin_149;
  int tempin_150;
  string tempst_151;
  int tempin_152;
  int tempin_153;
  int tempin_154;
  int tempin_155;
  int tempin_156;
  string tempst_157;
  int tempin_158;
  int tempin_159;
  int tempin_160;
  int tempin_161;
  int tempin_162;
  string tempst_163;
  int tempin_164;
  int tempin_165;
  int tempin_166;
  int tempin_167;
  int tempin_168;
  string tempst_169;
  int tempin_170;
  int tempin_171;
  int tempin_172;
  int tempin_173;
  int tempin_174;
  string tempst_175;
  int tempin_176;
  int tempin_177;
  int tempin_178;
  int tempin_179;
  int tempin_180;
  string tempst_181;
  int tempin_182;
  int tempin_183;
  int tempin_184;
  int tempin_185;
  int tempin_186;
  string tempst_187;
  int tempin_188;
  int tempin_189;
  int tempin_190;
  int tempin_191;
  int tempin_192;
  string tempst_193;
  int tempin_194;
  int tempin_195;
  int tempin_196;
  int tempin_197;
  int tempin_198;
  string tempst_199;
  int tempin_200;
  int tempin_201;
  int tempin_202;
  int tempin_203;
  int tempin_204;
  string tempst_205;
  int tempin_206;
  int tempin_207;
  int tempin_208;
  int tempin_209;
  int tempin_210;
  string tempst_211;
  int tempin_212;
  int tempin_213;
  int tempin_214;
  int tempin_215;
  int tempin_216;
  string tempst_217;
  int tempin_218;
  int tempin_219;
  int tempin_220;
  int tempin_221;
  int tempin_222;
  string tempst_223;
  int tempin_224;
  int tempin_225;
  int tempin_226;
  int tempin_227;
  int tempin_228;
  string tempst_229;
  int tempin_230;
  int tempin_231;
  int tempin_232;
  int tempin_233;
  int tempin_234;
  string tempst_235;
  int tempin_236;

  localInt_1 = 10;
  localInt_2 = 20;
  localInt_3 = g_FontSize * 210 / 100;
  localInt_4 = 310;
  if (!(CreateGraphicObject(0, "RectLabel", 0, 10, 20, localInt_3, 310, 8421504, 1, 0, 9109504, 0, 2, false, false, false, 1)))
    return;
  localInt_2 = 20 + 5;
  localInt_1 = g_FontSize * 5 / 100 + 10;
  localInt_5 = g_FontSize * 120 / 100;
  localInt_6 = 15;
  localString_7 = StringFormat("1:%I64d", AccountLeverage());
  localString_8 = "";
  if (g_AutoMMFactor > 0.0)
  {
    if (ArraySize(g_SymbolsArray) == 1)
    {
      tempst_1 = DoubleToString(USD_for_001, 0);
      if (g_SymbolMultiplierArray[0] == 1.0)
      {
        tempst_2 = "";
      }
      else
      {
        tempst_2 = "(*" + string(g_SymbolMultiplierArray[0]) + ")";
      }
      tempst_1 = tempst_1 + tempst_2;
      localString_8 = tempst_1;
    }
    else
    {
      localString_8 = DoubleToString(USD_for_001, 0);
    }
  }
  else
  {
    localString_8 = "fix lot=" + string(Lots);
  }
  tempin_3 = 16777215;
  tempin_4 = 11;
  tempin_5 = localInt_2;
  tempin_6 = localInt_1;
  tempst_7 = "NorthEastWay MT4 v" + g_EAVersion;
  if (ObjectFind(0, "s1") >= 0)
  {
    ObjectDelete(0, "s1");
  }
  if (ObjectCreate(0, "s1", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "s1", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "s1", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "s1", OBJPROP_XDISTANCE, tempin_6);
    ObjectSetInteger(0, "s1", OBJPROP_YDISTANCE, tempin_5);
    ObjectSetInteger(0, "s1", OBJPROP_FONTSIZE, tempin_4);
    ObjectSetInteger(0, "s1", OBJPROP_COLOR, tempin_3);
    ObjectSetInteger(0, "s1", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "s1", OBJPROP_TEXT, tempst_7);
    ObjectSetString(0, "s1", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "s1", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "s1", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "s1", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "s1", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_8 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_8] = "s1";
  }
  localInt_2 += localInt_6;
  tempin_9 = 16777215;
  tempin_10 = 9;
  tempin_11 = localInt_2;
  tempin_12 = localInt_1;
  tempst_13 = "-------------------------------";
  if (ObjectFind(0, "s2") >= 0)
  {
    ObjectDelete(0, "s2");
  }
  if (ObjectCreate(0, "s2", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "s2", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "s2", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "s2", OBJPROP_XDISTANCE, tempin_12);
    ObjectSetInteger(0, "s2", OBJPROP_YDISTANCE, tempin_11);
    ObjectSetInteger(0, "s2", OBJPROP_FONTSIZE, tempin_10);
    ObjectSetInteger(0, "s2", OBJPROP_COLOR, tempin_9);
    ObjectSetInteger(0, "s2", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "s2", OBJPROP_TEXT, tempst_13);
    ObjectSetString(0, "s2", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "s2", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "s2", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "s2", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "s2", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_14 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_14] = "s2";
  }
  localInt_2 += localInt_6;
  tempin_15 = 16777215;
  tempin_16 = 9;
  tempin_17 = localInt_2;
  tempin_18 = localInt_1;
  tempst_19 = "Acc leverage:";
  if (ObjectFind(0, "se1") >= 0)
  {
    ObjectDelete(0, "se1");
  }
  if (ObjectCreate(0, "se1", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "se1", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "se1", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "se1", OBJPROP_XDISTANCE, tempin_18);
    ObjectSetInteger(0, "se1", OBJPROP_YDISTANCE, tempin_17);
    ObjectSetInteger(0, "se1", OBJPROP_FONTSIZE, tempin_16);
    ObjectSetInteger(0, "se1", OBJPROP_COLOR, tempin_15);
    ObjectSetInteger(0, "se1", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "se1", OBJPROP_TEXT, tempst_19);
    ObjectSetString(0, "se1", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "se1", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "se1", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "se1", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "se1", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_20 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_20] = "se1";
  }
  tempin_21 = 16777215;
  tempin_22 = 9;
  tempin_23 = localInt_2;
  tempin_24 = localInt_1 + localInt_5;
  tempst_25 = localString_7;
  if (ObjectFind(0, "AccLever") >= 0)
  {
    ObjectDelete(0, "AccLever");
  }
  if (ObjectCreate(0, "AccLever", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "AccLever", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "AccLever", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "AccLever", OBJPROP_XDISTANCE, tempin_24);
    ObjectSetInteger(0, "AccLever", OBJPROP_YDISTANCE, tempin_23);
    ObjectSetInteger(0, "AccLever", OBJPROP_FONTSIZE, tempin_22);
    ObjectSetInteger(0, "AccLever", OBJPROP_COLOR, tempin_21);
    ObjectSetInteger(0, "AccLever", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "AccLever", OBJPROP_TEXT, tempst_25);
    ObjectSetString(0, "AccLever", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "AccLever", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "AccLever", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "AccLever", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "AccLever", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_26 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_26] = "AccLever";
  }
  localInt_2 += localInt_6;
  tempin_27 = 16777215;
  tempin_28 = 9;
  tempin_29 = localInt_2;
  tempin_30 = localInt_1;
  tempst_31 = "Currency:";
  if (ObjectFind(0, "curr_lab") >= 0)
  {
    ObjectDelete(0, "curr_lab");
  }
  if (ObjectCreate(0, "curr_lab", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "curr_lab", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "curr_lab", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "curr_lab", OBJPROP_XDISTANCE, tempin_30);
    ObjectSetInteger(0, "curr_lab", OBJPROP_YDISTANCE, tempin_29);
    ObjectSetInteger(0, "curr_lab", OBJPROP_FONTSIZE, tempin_28);
    ObjectSetInteger(0, "curr_lab", OBJPROP_COLOR, tempin_27);
    ObjectSetInteger(0, "curr_lab", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "curr_lab", OBJPROP_TEXT, tempst_31);
    ObjectSetString(0, "curr_lab", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "curr_lab", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "curr_lab", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "curr_lab", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "curr_lab", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_32 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_32] = "curr_lab";
  }
  tempin_33 = 16777215;
  tempin_34 = 9;
  tempin_35 = localInt_2;
  tempin_36 = localInt_1 + localInt_5;
  if (ArraySize(g_SymbolsArray) > 1)
  {
    tempst_37 = "Multi Mode";
  }
  else
  {
    tempst_37 = g_SymbolsArray[0];
  }
  tempst_37 = tempst_37;
  if (ObjectFind(0, "curr") >= 0)
  {
    ObjectDelete(0, "curr");
  }
  if (ObjectCreate(0, "curr", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "curr", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "curr", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "curr", OBJPROP_XDISTANCE, tempin_36);
    ObjectSetInteger(0, "curr", OBJPROP_YDISTANCE, tempin_35);
    ObjectSetInteger(0, "curr", OBJPROP_FONTSIZE, tempin_34);
    ObjectSetInteger(0, "curr", OBJPROP_COLOR, tempin_33);
    ObjectSetInteger(0, "curr", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "curr", OBJPROP_TEXT, tempst_37);
    ObjectSetString(0, "curr", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "curr", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "curr", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "curr", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "curr", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_38 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_38] = "curr";
  }
  localInt_2 += localInt_6;
  tempin_39 = 16777215;
  tempin_40 = 9;
  tempin_41 = localInt_2;
  tempin_42 = localInt_1;
  tempst_43 = "Base for lot calc:";
  if (ObjectFind(0, "base_calc_l") >= 0)
  {
    ObjectDelete(0, "base_calc_l");
  }
  if (ObjectCreate(0, "base_calc_l", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "base_calc_l", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "base_calc_l", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "base_calc_l", OBJPROP_XDISTANCE, tempin_42);
    ObjectSetInteger(0, "base_calc_l", OBJPROP_YDISTANCE, tempin_41);
    ObjectSetInteger(0, "base_calc_l", OBJPROP_FONTSIZE, tempin_40);
    ObjectSetInteger(0, "base_calc_l", OBJPROP_COLOR, tempin_39);
    ObjectSetInteger(0, "base_calc_l", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "base_calc_l", OBJPROP_TEXT, tempst_43);
    ObjectSetString(0, "base_calc_l", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "base_calc_l", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "base_calc_l", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "base_calc_l", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "base_calc_l", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_44 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_44] = "base_calc_l";
  }
  tempin_45 = 16777215;
  tempin_46 = 9;
  tempin_47 = localInt_2;
  tempin_48 = localInt_1 + localInt_5;
  if (fix_balance > 0.0)
  {
    tempst_49 = fix_balance;
  }
  else
  {
    tempst_49 = EnumToString(TypeBFLC(BaseForLotCalc));
  }
  tempst_49 = tempst_49;
  if (ObjectFind(0, "bace_calc") >= 0)
  {
    ObjectDelete(0, "bace_calc");
  }
  if (ObjectCreate(0, "bace_calc", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "bace_calc", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "bace_calc", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "bace_calc", OBJPROP_XDISTANCE, tempin_48);
    ObjectSetInteger(0, "bace_calc", OBJPROP_YDISTANCE, tempin_47);
    ObjectSetInteger(0, "bace_calc", OBJPROP_FONTSIZE, tempin_46);
    ObjectSetInteger(0, "bace_calc", OBJPROP_COLOR, tempin_45);
    ObjectSetInteger(0, "bace_calc", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "bace_calc", OBJPROP_TEXT, tempst_49);
    ObjectSetString(0, "bace_calc", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "bace_calc", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "bace_calc", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "bace_calc", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "bace_calc", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_50 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_50] = "bace_calc";
  }
  localInt_2 += localInt_6;
  tempin_51 = 16777215;
  tempin_52 = 9;
  tempin_53 = localInt_2;
  tempin_54 = localInt_1;
  tempst_55 = "AutoMM:";
  if (ObjectFind(0, "se21") >= 0)
  {
    ObjectDelete(0, "se21");
  }
  if (ObjectCreate(0, "se21", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "se21", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "se21", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "se21", OBJPROP_XDISTANCE, tempin_54);
    ObjectSetInteger(0, "se21", OBJPROP_YDISTANCE, tempin_53);
    ObjectSetInteger(0, "se21", OBJPROP_FONTSIZE, tempin_52);
    ObjectSetInteger(0, "se21", OBJPROP_COLOR, tempin_51);
    ObjectSetInteger(0, "se21", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "se21", OBJPROP_TEXT, tempst_55);
    ObjectSetString(0, "se21", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "se21", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "se21", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "se21", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "se21", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_56 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_56] = "se21";
  }
  tempin_57 = 16777215;
  tempin_58 = 9;
  tempin_59 = localInt_2;
  tempin_60 = localInt_1 + localInt_5;
  tempst_61 = localString_8;
  if (ObjectFind(0, "AutoMM") >= 0)
  {
    ObjectDelete(0, "AutoMM");
  }
  if (ObjectCreate(0, "AutoMM", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "AutoMM", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "AutoMM", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "AutoMM", OBJPROP_XDISTANCE, tempin_60);
    ObjectSetInteger(0, "AutoMM", OBJPROP_YDISTANCE, tempin_59);
    ObjectSetInteger(0, "AutoMM", OBJPROP_FONTSIZE, tempin_58);
    ObjectSetInteger(0, "AutoMM", OBJPROP_COLOR, tempin_57);
    ObjectSetInteger(0, "AutoMM", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "AutoMM", OBJPROP_TEXT, tempst_61);
    ObjectSetString(0, "AutoMM", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "AutoMM", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "AutoMM", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "AutoMM", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "AutoMM", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_62 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_62] = "AutoMM";
  }
  localInt_2 += localInt_6;
  tempin_63 = 16777215;
  tempin_64 = 9;
  tempin_65 = localInt_2;
  tempin_66 = localInt_1;
  tempst_67 = "First Real Deal:";
  if (ObjectFind(0, "frd_1") >= 0)
  {
    ObjectDelete(0, "frd_1");
  }
  if (ObjectCreate(0, "frd_1", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "frd_1", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "frd_1", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "frd_1", OBJPROP_XDISTANCE, tempin_66);
    ObjectSetInteger(0, "frd_1", OBJPROP_YDISTANCE, tempin_65);
    ObjectSetInteger(0, "frd_1", OBJPROP_FONTSIZE, tempin_64);
    ObjectSetInteger(0, "frd_1", OBJPROP_COLOR, tempin_63);
    ObjectSetInteger(0, "frd_1", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "frd_1", OBJPROP_TEXT, tempst_67);
    ObjectSetString(0, "frd_1", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "frd_1", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "frd_1", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "frd_1", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "frd_1", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_68 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_68] = "frd_1";
  }
  tempin_69 = 16777215;
  tempin_70 = 9;
  tempin_71 = localInt_2;
  tempin_72 = localInt_1 + localInt_5;
  tempst_73 = FirstNumberp;
  if (ObjectFind(0, "frd") >= 0)
  {
    ObjectDelete(0, "frd");
  }
  if (ObjectCreate(0, "frd", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "frd", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "frd", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "frd", OBJPROP_XDISTANCE, tempin_72);
    ObjectSetInteger(0, "frd", OBJPROP_YDISTANCE, tempin_71);
    ObjectSetInteger(0, "frd", OBJPROP_FONTSIZE, tempin_70);
    ObjectSetInteger(0, "frd", OBJPROP_COLOR, tempin_69);
    ObjectSetInteger(0, "frd", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "frd", OBJPROP_TEXT, tempst_73);
    ObjectSetString(0, "frd", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "frd", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "frd", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "frd", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "frd", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_74 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_74] = "frd";
  }
  localInt_2 += localInt_6;
  tempin_75 = 16777215;
  tempin_76 = 9;
  tempin_77 = localInt_2;
  tempin_78 = localInt_1;
  tempst_79 = "Base lot:";
  if (ObjectFind(0, "se2") >= 0)
  {
    ObjectDelete(0, "se2");
  }
  if (ObjectCreate(0, "se2", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "se2", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "se2", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "se2", OBJPROP_XDISTANCE, tempin_78);
    ObjectSetInteger(0, "se2", OBJPROP_YDISTANCE, tempin_77);
    ObjectSetInteger(0, "se2", OBJPROP_FONTSIZE, tempin_76);
    ObjectSetInteger(0, "se2", OBJPROP_COLOR, tempin_75);
    ObjectSetInteger(0, "se2", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "se2", OBJPROP_TEXT, tempst_79);
    ObjectSetString(0, "se2", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "se2", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "se2", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "se2", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "se2", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_80 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_80] = "se2";
  }
  tempin_81 = 16777215;
  tempin_82 = 9;
  tempin_83 = localInt_2;
  tempin_84 = localInt_1 + localInt_5;
  tempst_85 = "0";
  if (ObjectFind(0, "Sizelot") >= 0)
  {
    ObjectDelete(0, "Sizelot");
  }
  if (ObjectCreate(0, "Sizelot", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "Sizelot", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "Sizelot", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "Sizelot", OBJPROP_XDISTANCE, tempin_84);
    ObjectSetInteger(0, "Sizelot", OBJPROP_YDISTANCE, tempin_83);
    ObjectSetInteger(0, "Sizelot", OBJPROP_FONTSIZE, tempin_82);
    ObjectSetInteger(0, "Sizelot", OBJPROP_COLOR, tempin_81);
    ObjectSetInteger(0, "Sizelot", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "Sizelot", OBJPROP_TEXT, tempst_85);
    ObjectSetString(0, "Sizelot", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "Sizelot", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "Sizelot", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "Sizelot", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "Sizelot", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_86 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_86] = "Sizelot";
  }
  localInt_2 += localInt_6;
  tempin_87 = 16777215;
  tempin_88 = 9;
  tempin_89 = localInt_2;
  tempin_90 = localInt_1;
  tempst_91 = "Recovery?:";
  if (ObjectFind(0, "se3") >= 0)
  {
    ObjectDelete(0, "se3");
  }
  if (ObjectCreate(0, "se3", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "se3", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "se3", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "se3", OBJPROP_XDISTANCE, tempin_90);
    ObjectSetInteger(0, "se3", OBJPROP_YDISTANCE, tempin_89);
    ObjectSetInteger(0, "se3", OBJPROP_FONTSIZE, tempin_88);
    ObjectSetInteger(0, "se3", OBJPROP_COLOR, tempin_87);
    ObjectSetInteger(0, "se3", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "se3", OBJPROP_TEXT, tempst_91);
    ObjectSetString(0, "se3", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "se3", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "se3", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "se3", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "se3", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_92 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_92] = "se3";
  }
  tempin_93 = 16777215;
  tempin_94 = 9;
  tempin_95 = localInt_2;
  tempin_96 = localInt_1 + localInt_5;
  tempst_97 = UseUnloss;
  if (ObjectFind(0, "Recovery") >= 0)
  {
    ObjectDelete(0, "Recovery");
  }
  if (ObjectCreate(0, "Recovery", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "Recovery", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "Recovery", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "Recovery", OBJPROP_XDISTANCE, tempin_96);
    ObjectSetInteger(0, "Recovery", OBJPROP_YDISTANCE, tempin_95);
    ObjectSetInteger(0, "Recovery", OBJPROP_FONTSIZE, tempin_94);
    ObjectSetInteger(0, "Recovery", OBJPROP_COLOR, tempin_93);
    ObjectSetInteger(0, "Recovery", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "Recovery", OBJPROP_TEXT, tempst_97);
    ObjectSetString(0, "Recovery", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "Recovery", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "Recovery", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "Recovery", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "Recovery", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_98 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_98] = "Recovery";
  }
  localInt_2 += localInt_6;
  tempin_99 = 16777215;
  tempin_100 = 9;
  tempin_101 = localInt_2;
  tempin_102 = localInt_1;
  tempst_103 = "Comment:";
  if (ObjectFind(0, "se4") >= 0)
  {
    ObjectDelete(0, "se4");
  }
  if (ObjectCreate(0, "se4", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "se4", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "se4", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "se4", OBJPROP_XDISTANCE, tempin_102);
    ObjectSetInteger(0, "se4", OBJPROP_YDISTANCE, tempin_101);
    ObjectSetInteger(0, "se4", OBJPROP_FONTSIZE, tempin_100);
    ObjectSetInteger(0, "se4", OBJPROP_COLOR, tempin_99);
    ObjectSetInteger(0, "se4", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "se4", OBJPROP_TEXT, tempst_103);
    ObjectSetString(0, "se4", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "se4", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "se4", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "se4", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "se4", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_104 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_104] = "se4";
  }
  tempin_105 = 16777215;
  tempin_106 = 9;
  tempin_107 = localInt_2;
  tempin_108 = localInt_1 + localInt_5;
  tempst_109 = ".";
  if (ObjectFind(0, "Comment") >= 0)
  {
    ObjectDelete(0, "Comment");
  }
  if (ObjectCreate(0, "Comment", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "Comment", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "Comment", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "Comment", OBJPROP_XDISTANCE, tempin_108);
    ObjectSetInteger(0, "Comment", OBJPROP_YDISTANCE, tempin_107);
    ObjectSetInteger(0, "Comment", OBJPROP_FONTSIZE, tempin_106);
    ObjectSetInteger(0, "Comment", OBJPROP_COLOR, tempin_105);
    ObjectSetInteger(0, "Comment", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "Comment", OBJPROP_TEXT, tempst_109);
    ObjectSetString(0, "Comment", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "Comment", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "Comment", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "Comment", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "Comment", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_110 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_110] = "Comment";
  }
  localInt_2 += localInt_6;
  tempin_111 = 16777215;
  tempin_112 = 9;
  tempin_113 = localInt_2;
  tempin_114 = localInt_1;
  tempst_115 = "-------------------------------";
  if (ObjectFind(0, "s3") >= 0)
  {
    ObjectDelete(0, "s3");
  }
  if (ObjectCreate(0, "s3", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "s3", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "s3", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "s3", OBJPROP_XDISTANCE, tempin_114);
    ObjectSetInteger(0, "s3", OBJPROP_YDISTANCE, tempin_113);
    ObjectSetInteger(0, "s3", OBJPROP_FONTSIZE, tempin_112);
    ObjectSetInteger(0, "s3", OBJPROP_COLOR, tempin_111);
    ObjectSetInteger(0, "s3", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "s3", OBJPROP_TEXT, tempst_115);
    ObjectSetString(0, "s3", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "s3", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "s3", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "s3", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "s3", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_116 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_116] = "s3";
  }
  localInt_2 += localInt_6;
  if (virtBalance != 0.0 && USD_for_001 > 0.0)
  {
    tempin_117 = 16777215;
    tempin_118 = 9;
    tempin_119 = localInt_2;
    tempin_120 = localInt_1;
    tempst_121 = "Full Balance:";
    if (ObjectFind(0, "lt40") >= 0)
    {
      ObjectDelete(0, "lt40");
    }
    if (ObjectCreate(0, "lt40", 23, 0, 0, 0.0))
    {
      ObjectSetInteger(0, "lt40", OBJPROP_ANCHOR, 0);
      ObjectSetInteger(0, "lt40", OBJPROP_CORNER, 0);
      ObjectSetInteger(0, "lt40", OBJPROP_XDISTANCE, tempin_120);
      ObjectSetInteger(0, "lt40", OBJPROP_YDISTANCE, tempin_119);
      ObjectSetInteger(0, "lt40", OBJPROP_FONTSIZE, tempin_118);
      ObjectSetInteger(0, "lt40", OBJPROP_COLOR, tempin_117);
      ObjectSetInteger(0, "lt40", OBJPROP_SELECTABLE, 1);
      ObjectSetString(0, "lt40", OBJPROP_TEXT, tempst_121);
      ObjectSetString(0, "lt40", OBJPROP_FONT, "Calibri");
      ObjectSetInteger(0, "lt40", OBJPROP_SELECTED, 0);
      ObjectSetInteger(0, "lt40", OBJPROP_HIDDEN, 0);
      ObjectSetInteger(0, "lt40", OBJPROP_ZORDER, 1);
      ObjectSetInteger(0, "lt40", OBJPROP_SELECTABLE, 0);
      ChartRedraw(0);
      tempin_122 = ArraySize(g_SymbolListArray);
      ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
      g_SymbolListArray[tempin_122] = "lt40";
    }
    tempin_123 = 16777215;
    tempin_124 = 9;
    tempin_125 = localInt_2;
    tempin_126 = localInt_1 + localInt_5;
    tempst_127 = "0.0";
    if (ObjectFind(0, "FullBalance") >= 0)
    {
      ObjectDelete(0, "FullBalance");
    }
    if (ObjectCreate(0, "FullBalance", 23, 0, 0, 0.0))
    {
      ObjectSetInteger(0, "FullBalance", OBJPROP_ANCHOR, 0);
      ObjectSetInteger(0, "FullBalance", OBJPROP_CORNER, 0);
      ObjectSetInteger(0, "FullBalance", OBJPROP_XDISTANCE, tempin_126);
      ObjectSetInteger(0, "FullBalance", OBJPROP_YDISTANCE, tempin_125);
      ObjectSetInteger(0, "FullBalance", OBJPROP_FONTSIZE, tempin_124);
      ObjectSetInteger(0, "FullBalance", OBJPROP_COLOR, tempin_123);
      ObjectSetInteger(0, "FullBalance", OBJPROP_SELECTABLE, 1);
      ObjectSetString(0, "FullBalance", OBJPROP_TEXT, tempst_127);
      ObjectSetString(0, "FullBalance", OBJPROP_FONT, "Calibri");
      ObjectSetInteger(0, "FullBalance", OBJPROP_SELECTED, 0);
      ObjectSetInteger(0, "FullBalance", OBJPROP_HIDDEN, 0);
      ObjectSetInteger(0, "FullBalance", OBJPROP_ZORDER, 1);
      ObjectSetInteger(0, "FullBalance", OBJPROP_SELECTABLE, 0);
      ChartRedraw(0);
      tempin_128 = ArraySize(g_SymbolListArray);
      ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
      g_SymbolListArray[tempin_128] = "FullBalance";
    }
    localInt_2 += localInt_6;
    tempin_129 = 16777215;
    tempin_130 = 9;
    tempin_131 = localInt_2;
    tempin_132 = localInt_1;
    tempst_133 = "Full Equity:";
    if (ObjectFind(0, "lt410") >= 0)
    {
      ObjectDelete(0, "lt410");
    }
    if (ObjectCreate(0, "lt410", 23, 0, 0, 0.0))
    {
      ObjectSetInteger(0, "lt410", OBJPROP_ANCHOR, 0);
      ObjectSetInteger(0, "lt410", OBJPROP_CORNER, 0);
      ObjectSetInteger(0, "lt410", OBJPROP_XDISTANCE, tempin_132);
      ObjectSetInteger(0, "lt410", OBJPROP_YDISTANCE, tempin_131);
      ObjectSetInteger(0, "lt410", OBJPROP_FONTSIZE, tempin_130);
      ObjectSetInteger(0, "lt410", OBJPROP_COLOR, tempin_129);
      ObjectSetInteger(0, "lt410", OBJPROP_SELECTABLE, 1);
      ObjectSetString(0, "lt410", OBJPROP_TEXT, tempst_133);
      ObjectSetString(0, "lt410", OBJPROP_FONT, "Calibri");
      ObjectSetInteger(0, "lt410", OBJPROP_SELECTED, 0);
      ObjectSetInteger(0, "lt410", OBJPROP_HIDDEN, 0);
      ObjectSetInteger(0, "lt410", OBJPROP_ZORDER, 1);
      ObjectSetInteger(0, "lt410", OBJPROP_SELECTABLE, 0);
      ChartRedraw(0);
      tempin_134 = ArraySize(g_SymbolListArray);
      ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
      g_SymbolListArray[tempin_134] = "lt410";
    }
    tempin_135 = 16777215;
    tempin_136 = 9;
    tempin_137 = localInt_2;
    tempin_138 = localInt_1 + localInt_5;
    tempst_139 = "0.0";
    if (ObjectFind(0, "FullEquity") >= 0)
    {
      ObjectDelete(0, "FullEquity");
    }
    if (ObjectCreate(0, "FullEquity", 23, 0, 0, 0.0))
    {
      ObjectSetInteger(0, "FullEquity", OBJPROP_ANCHOR, 0);
      ObjectSetInteger(0, "FullEquity", OBJPROP_CORNER, 0);
      ObjectSetInteger(0, "FullEquity", OBJPROP_XDISTANCE, tempin_138);
      ObjectSetInteger(0, "FullEquity", OBJPROP_YDISTANCE, tempin_137);
      ObjectSetInteger(0, "FullEquity", OBJPROP_FONTSIZE, tempin_136);
      ObjectSetInteger(0, "FullEquity", OBJPROP_COLOR, tempin_135);
      ObjectSetInteger(0, "FullEquity", OBJPROP_SELECTABLE, 1);
      ObjectSetString(0, "FullEquity", OBJPROP_TEXT, tempst_139);
      ObjectSetString(0, "FullEquity", OBJPROP_FONT, "Calibri");
      ObjectSetInteger(0, "FullEquity", OBJPROP_SELECTED, 0);
      ObjectSetInteger(0, "FullEquity", OBJPROP_HIDDEN, 0);
      ObjectSetInteger(0, "FullEquity", OBJPROP_ZORDER, 1);
      ObjectSetInteger(0, "FullEquity", OBJPROP_SELECTABLE, 0);
      ChartRedraw(0);
      tempin_140 = ArraySize(g_SymbolListArray);
      ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
      g_SymbolListArray[tempin_140] = "FullEquity";
    }
    localInt_2 += localInt_6;
    if (ObjectSetInteger(0, "RectLabel", OBJPROP_YSIZE, localInt_4 + localInt_6 * 2))
    {
      ChartRedraw(0);
    }
  }
  tempin_141 = 16777215;
  tempin_142 = 9;
  tempin_143 = localInt_2;
  tempin_144 = localInt_1;
  tempst_145 = "Balance:";
  if (ObjectFind(0, "lt4") >= 0)
  {
    ObjectDelete(0, "lt4");
  }
  if (ObjectCreate(0, "lt4", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "lt4", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "lt4", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "lt4", OBJPROP_XDISTANCE, tempin_144);
    ObjectSetInteger(0, "lt4", OBJPROP_YDISTANCE, tempin_143);
    ObjectSetInteger(0, "lt4", OBJPROP_FONTSIZE, tempin_142);
    ObjectSetInteger(0, "lt4", OBJPROP_COLOR, tempin_141);
    ObjectSetInteger(0, "lt4", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "lt4", OBJPROP_TEXT, tempst_145);
    ObjectSetString(0, "lt4", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "lt4", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "lt4", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "lt4", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "lt4", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_146 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_146] = "lt4";
  }
  tempin_147 = 16777215;
  tempin_148 = 9;
  tempin_149 = localInt_2;
  tempin_150 = localInt_1 + localInt_5;
  tempst_151 = "0.0";
  if (ObjectFind(0, "Balance") >= 0)
  {
    ObjectDelete(0, "Balance");
  }
  if (ObjectCreate(0, "Balance", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "Balance", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "Balance", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "Balance", OBJPROP_XDISTANCE, tempin_150);
    ObjectSetInteger(0, "Balance", OBJPROP_YDISTANCE, tempin_149);
    ObjectSetInteger(0, "Balance", OBJPROP_FONTSIZE, tempin_148);
    ObjectSetInteger(0, "Balance", OBJPROP_COLOR, tempin_147);
    ObjectSetInteger(0, "Balance", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "Balance", OBJPROP_TEXT, tempst_151);
    ObjectSetString(0, "Balance", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "Balance", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "Balance", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "Balance", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "Balance", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_152 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_152] = "Balance";
  }
  localInt_2 += localInt_6;
  tempin_153 = 16777215;
  tempin_154 = 9;
  tempin_155 = localInt_2;
  tempin_156 = localInt_1;
  tempst_157 = "Equity:";
  if (ObjectFind(0, "lt41") >= 0)
  {
    ObjectDelete(0, "lt41");
  }
  if (ObjectCreate(0, "lt41", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "lt41", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "lt41", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "lt41", OBJPROP_XDISTANCE, tempin_156);
    ObjectSetInteger(0, "lt41", OBJPROP_YDISTANCE, tempin_155);
    ObjectSetInteger(0, "lt41", OBJPROP_FONTSIZE, tempin_154);
    ObjectSetInteger(0, "lt41", OBJPROP_COLOR, tempin_153);
    ObjectSetInteger(0, "lt41", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "lt41", OBJPROP_TEXT, tempst_157);
    ObjectSetString(0, "lt41", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "lt41", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "lt41", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "lt41", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "lt41", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_158 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_158] = "lt41";
  }
  tempin_159 = 16777215;
  tempin_160 = 9;
  tempin_161 = localInt_2;
  tempin_162 = localInt_1 + localInt_5;
  tempst_163 = "0.0";
  if (ObjectFind(0, "Equity") >= 0)
  {
    ObjectDelete(0, "Equity");
  }
  if (ObjectCreate(0, "Equity", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "Equity", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "Equity", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "Equity", OBJPROP_XDISTANCE, tempin_162);
    ObjectSetInteger(0, "Equity", OBJPROP_YDISTANCE, tempin_161);
    ObjectSetInteger(0, "Equity", OBJPROP_FONTSIZE, tempin_160);
    ObjectSetInteger(0, "Equity", OBJPROP_COLOR, tempin_159);
    ObjectSetInteger(0, "Equity", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "Equity", OBJPROP_TEXT, tempst_163);
    ObjectSetString(0, "Equity", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "Equity", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "Equity", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "Equity", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "Equity", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_164 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_164] = "Equity";
  }
  localInt_2 += localInt_6;
  tempin_165 = 16777215;
  tempin_166 = 9;
  tempin_167 = localInt_2;
  tempin_168 = localInt_1;
  tempst_169 = "Floating Profit:";
  if (ObjectFind(0, "lt5") >= 0)
  {
    ObjectDelete(0, "lt5");
  }
  if (ObjectCreate(0, "lt5", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "lt5", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "lt5", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "lt5", OBJPROP_XDISTANCE, tempin_168);
    ObjectSetInteger(0, "lt5", OBJPROP_YDISTANCE, tempin_167);
    ObjectSetInteger(0, "lt5", OBJPROP_FONTSIZE, tempin_166);
    ObjectSetInteger(0, "lt5", OBJPROP_COLOR, tempin_165);
    ObjectSetInteger(0, "lt5", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "lt5", OBJPROP_TEXT, tempst_169);
    ObjectSetString(0, "lt5", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "lt5", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "lt5", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "lt5", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "lt5", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_170 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_170] = "lt5";
  }
  tempin_171 = 16777215;
  tempin_172 = 9;
  tempin_173 = localInt_2;
  tempin_174 = localInt_1 + localInt_5;
  tempst_175 = "0.0";
  if (ObjectFind(0, "FloatProf") >= 0)
  {
    ObjectDelete(0, "FloatProf");
  }
  if (ObjectCreate(0, "FloatProf", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "FloatProf", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "FloatProf", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "FloatProf", OBJPROP_XDISTANCE, tempin_174);
    ObjectSetInteger(0, "FloatProf", OBJPROP_YDISTANCE, tempin_173);
    ObjectSetInteger(0, "FloatProf", OBJPROP_FONTSIZE, tempin_172);
    ObjectSetInteger(0, "FloatProf", OBJPROP_COLOR, tempin_171);
    ObjectSetInteger(0, "FloatProf", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "FloatProf", OBJPROP_TEXT, tempst_175);
    ObjectSetString(0, "FloatProf", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "FloatProf", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "FloatProf", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "FloatProf", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "FloatProf", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_176 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_176] = "FloatProf";
  }
  localInt_2 += localInt_6;
  tempin_177 = 16777215;
  tempin_178 = 9;
  tempin_179 = localInt_2;
  tempin_180 = localInt_1;
  tempst_181 = "Floating Profit %:";
  if (ObjectFind(0, "lt3") >= 0)
  {
    ObjectDelete(0, "lt3");
  }
  if (ObjectCreate(0, "lt3", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "lt3", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "lt3", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "lt3", OBJPROP_XDISTANCE, tempin_180);
    ObjectSetInteger(0, "lt3", OBJPROP_YDISTANCE, tempin_179);
    ObjectSetInteger(0, "lt3", OBJPROP_FONTSIZE, tempin_178);
    ObjectSetInteger(0, "lt3", OBJPROP_COLOR, tempin_177);
    ObjectSetInteger(0, "lt3", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "lt3", OBJPROP_TEXT, tempst_181);
    ObjectSetString(0, "lt3", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "lt3", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "lt3", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "lt3", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "lt3", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_182 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_182] = "lt3";
  }
  tempin_183 = 16777215;
  tempin_184 = 9;
  tempin_185 = localInt_2;
  tempin_186 = localInt_1 + localInt_5;
  tempst_187 = "0.0%";
  if (ObjectFind(0, "FloatProf%") >= 0)
  {
    ObjectDelete(0, "FloatProf%");
  }
  if (ObjectCreate(0, "FloatProf%", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "FloatProf%", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "FloatProf%", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "FloatProf%", OBJPROP_XDISTANCE, tempin_186);
    ObjectSetInteger(0, "FloatProf%", OBJPROP_YDISTANCE, tempin_185);
    ObjectSetInteger(0, "FloatProf%", OBJPROP_FONTSIZE, tempin_184);
    ObjectSetInteger(0, "FloatProf%", OBJPROP_COLOR, tempin_183);
    ObjectSetInteger(0, "FloatProf%", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "FloatProf%", OBJPROP_TEXT, tempst_187);
    ObjectSetString(0, "FloatProf%", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "FloatProf%", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "FloatProf%", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "FloatProf%", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "FloatProf%", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_188 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_188] = "FloatProf%";
  }
  localInt_2 += localInt_6;
  tempin_189 = 16777215;
  tempin_190 = 9;
  tempin_191 = localInt_2;
  tempin_192 = localInt_1;
  tempst_193 = "Open Lots:";
  if (ObjectFind(0, "lt2") >= 0)
  {
    ObjectDelete(0, "lt2");
  }
  if (ObjectCreate(0, "lt2", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "lt2", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "lt2", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "lt2", OBJPROP_XDISTANCE, tempin_192);
    ObjectSetInteger(0, "lt2", OBJPROP_YDISTANCE, tempin_191);
    ObjectSetInteger(0, "lt2", OBJPROP_FONTSIZE, tempin_190);
    ObjectSetInteger(0, "lt2", OBJPROP_COLOR, tempin_189);
    ObjectSetInteger(0, "lt2", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "lt2", OBJPROP_TEXT, tempst_193);
    ObjectSetString(0, "lt2", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "lt2", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "lt2", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "lt2", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "lt2", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_194 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_194] = "lt2";
  }
  tempin_195 = 16777215;
  tempin_196 = 9;
  tempin_197 = localInt_2;
  tempin_198 = localInt_1 + localInt_5;
  tempst_199 = "0.0";
  if (ObjectFind(0, "OpenLots") >= 0)
  {
    ObjectDelete(0, "OpenLots");
  }
  if (ObjectCreate(0, "OpenLots", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "OpenLots", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "OpenLots", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "OpenLots", OBJPROP_XDISTANCE, tempin_198);
    ObjectSetInteger(0, "OpenLots", OBJPROP_YDISTANCE, tempin_197);
    ObjectSetInteger(0, "OpenLots", OBJPROP_FONTSIZE, tempin_196);
    ObjectSetInteger(0, "OpenLots", OBJPROP_COLOR, tempin_195);
    ObjectSetInteger(0, "OpenLots", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "OpenLots", OBJPROP_TEXT, tempst_199);
    ObjectSetString(0, "OpenLots", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "OpenLots", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "OpenLots", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "OpenLots", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "OpenLots", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_200 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_200] = "OpenLots";
  }
  localInt_2 += localInt_6;
  tempin_201 = 16777215;
  tempin_202 = 9;
  tempin_203 = localInt_2;
  tempin_204 = localInt_1;
  tempst_205 = "Current leverage:";
  if (ObjectFind(0, "lt1") >= 0)
  {
    ObjectDelete(0, "lt1");
  }
  if (ObjectCreate(0, "lt1", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "lt1", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "lt1", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "lt1", OBJPROP_XDISTANCE, tempin_204);
    ObjectSetInteger(0, "lt1", OBJPROP_YDISTANCE, tempin_203);
    ObjectSetInteger(0, "lt1", OBJPROP_FONTSIZE, tempin_202);
    ObjectSetInteger(0, "lt1", OBJPROP_COLOR, tempin_201);
    ObjectSetInteger(0, "lt1", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "lt1", OBJPROP_TEXT, tempst_205);
    ObjectSetString(0, "lt1", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "lt1", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "lt1", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "lt1", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "lt1", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_206 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_206] = "lt1";
  }
  tempin_207 = 16777215;
  tempin_208 = 9;
  tempin_209 = localInt_2;
  tempin_210 = localInt_1 + localInt_5;
  tempst_211 = ":";
  if (ObjectFind(0, "CurrLev") >= 0)
  {
    ObjectDelete(0, "CurrLev");
  }
  if (ObjectCreate(0, "CurrLev", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "CurrLev", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "CurrLev", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "CurrLev", OBJPROP_XDISTANCE, tempin_210);
    ObjectSetInteger(0, "CurrLev", OBJPROP_YDISTANCE, tempin_209);
    ObjectSetInteger(0, "CurrLev", OBJPROP_FONTSIZE, tempin_208);
    ObjectSetInteger(0, "CurrLev", OBJPROP_COLOR, tempin_207);
    ObjectSetInteger(0, "CurrLev", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "CurrLev", OBJPROP_TEXT, tempst_211);
    ObjectSetString(0, "CurrLev", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "CurrLev", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "CurrLev", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "CurrLev", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "CurrLev", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_212 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_212] = "CurrLev";
  }
  localInt_2 += localInt_6;
  tempin_213 = 16777215;
  tempin_214 = 9;
  tempin_215 = localInt_2;
  tempin_216 = localInt_1;
  tempst_217 = "Current spread:";
  if (ObjectFind(0, "spread_lb") >= 0)
  {
    ObjectDelete(0, "spread_lb");
  }
  if (ObjectCreate(0, "spread_lb", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "spread_lb", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "spread_lb", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "spread_lb", OBJPROP_XDISTANCE, tempin_216);
    ObjectSetInteger(0, "spread_lb", OBJPROP_YDISTANCE, tempin_215);
    ObjectSetInteger(0, "spread_lb", OBJPROP_FONTSIZE, tempin_214);
    ObjectSetInteger(0, "spread_lb", OBJPROP_COLOR, tempin_213);
    ObjectSetInteger(0, "spread_lb", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "spread_lb", OBJPROP_TEXT, tempst_217);
    ObjectSetString(0, "spread_lb", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "spread_lb", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "spread_lb", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "spread_lb", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "spread_lb", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_218 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_218] = "spread_lb";
  }
  tempin_219 = 16777215;
  tempin_220 = 9;
  tempin_221 = localInt_2;
  tempin_222 = localInt_1 + localInt_5;
  tempst_223 = "0";
  if (ObjectFind(0, "spread") >= 0)
  {
    ObjectDelete(0, "spread");
  }
  if (ObjectCreate(0, "spread", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "spread", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "spread", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "spread", OBJPROP_XDISTANCE, tempin_222);
    ObjectSetInteger(0, "spread", OBJPROP_YDISTANCE, tempin_221);
    ObjectSetInteger(0, "spread", OBJPROP_FONTSIZE, tempin_220);
    ObjectSetInteger(0, "spread", OBJPROP_COLOR, tempin_219);
    ObjectSetInteger(0, "spread", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "spread", OBJPROP_TEXT, tempst_223);
    ObjectSetString(0, "spread", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "spread", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "spread", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "spread", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "spread", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_224 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_224] = "spread";
  }
  localInt_2 += localInt_6;
  tempin_225 = 16777215;
  tempin_226 = 9;
  tempin_227 = localInt_2;
  tempin_228 = localInt_1;
  tempst_229 = "-------------------------------";
  if (ObjectFind(0, "f1") >= 0)
  {
    ObjectDelete(0, "f1");
  }
  if (ObjectCreate(0, "f1", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "f1", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "f1", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "f1", OBJPROP_XDISTANCE, tempin_228);
    ObjectSetInteger(0, "f1", OBJPROP_YDISTANCE, tempin_227);
    ObjectSetInteger(0, "f1", OBJPROP_FONTSIZE, tempin_226);
    ObjectSetInteger(0, "f1", OBJPROP_COLOR, tempin_225);
    ObjectSetInteger(0, "f1", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "f1", OBJPROP_TEXT, tempst_229);
    ObjectSetString(0, "f1", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "f1", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "f1", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "f1", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "f1", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_230 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_230] = "f1";
  }
  localInt_2 += localInt_6;
  tempin_231 = 16711680;
  tempin_232 = 9;
  tempin_233 = localInt_2;
  tempin_234 = localInt_1;
  tempst_235 = ".";
  if (ObjectFind(0, "TradingMode") >= 0)
  {
    ObjectDelete(0, "TradingMode");
  }
  if (ObjectCreate(0, "TradingMode", 23, 0, 0, 0.0))
  {
    ObjectSetInteger(0, "TradingMode", OBJPROP_ANCHOR, 0);
    ObjectSetInteger(0, "TradingMode", OBJPROP_CORNER, 0);
    ObjectSetInteger(0, "TradingMode", OBJPROP_XDISTANCE, tempin_234);
    ObjectSetInteger(0, "TradingMode", OBJPROP_YDISTANCE, tempin_233);
    ObjectSetInteger(0, "TradingMode", OBJPROP_FONTSIZE, tempin_232);
    ObjectSetInteger(0, "TradingMode", OBJPROP_COLOR, tempin_231);
    ObjectSetInteger(0, "TradingMode", OBJPROP_SELECTABLE, 1);
    ObjectSetString(0, "TradingMode", OBJPROP_TEXT, tempst_235);
    ObjectSetString(0, "TradingMode", OBJPROP_FONT, "Calibri");
    ObjectSetInteger(0, "TradingMode", OBJPROP_SELECTED, 0);
    ObjectSetInteger(0, "TradingMode", OBJPROP_HIDDEN, 0);
    ObjectSetInteger(0, "TradingMode", OBJPROP_ZORDER, 1);
    ObjectSetInteger(0, "TradingMode", OBJPROP_SELECTABLE, 0);
    ChartRedraw(0);
    tempin_236 = ArraySize(g_SymbolListArray);
    ArrayResize(g_SymbolListArray, ArraySize(g_SymbolListArray) + 1, 0);
    g_SymbolListArray[tempin_236] = "TradingMode";
  }
  localInt_2 += localInt_6;
  if (ObjectSetString(0, "Comment", OBJPROP_TEXT, comment))
  {
    ChartRedraw(0);
  }
  ChartRedraw(0);
  UpdateDashboardInfo();
}
// CreateDashboardPanel <<==--------   --------
void UpdateDashboardInfo()
{
  string localString_1;
  double localDouble_2;
  double localDouble_3;
  double localDouble_4;
  double localDouble_5;
  double localDouble_6;
  double localDouble_7;
  string localString_8;
  string localString_9;
  string localString_10;
  double localDouble_11;
  double localDouble_12;
  //----- -----
  string tempst_1;
  int tempin_2;
  int tempin_3;
  string tempst_4;
  double tempdo_5;
  int tempin_6;
  int tempin_7;
  int tempin_8;
  int tempin_9;
  string tempst_10;
  double tempdo_11;
  int tempin_12;
  int tempin_13;
  double tempdo_14;
  double tempdo_15;
  double tempdo_16;
  double tempdo_17;
  double tempdo_18;
  string tempst_19;
  bool tempbo_20;

  if (ArraySize(g_SymbolsArray) > 1)
  {
    localString_1 = "";
    tempst_1 = "";
  }
  else
  {
    localString_1 = g_CurrentSymbol;
    tempst_1 = g_CurrentSymbol;
  }
  localString_1 = tempst_1;
  tempin_2 = -1;
  tempin_3 = -1;
  tempst_4 = localString_1;
  tempdo_5 = 0.0;
  tempin_6 = 0;
  tempin_7 = OrdersTotal();
  if (localString_1 == "0")
  {
    tempst_4 = g_CurrentSymbol;
  }
  for (tempin_6 = 0; tempin_6 < tempin_7; tempin_6 = tempin_6 + 1)
  {
    if (!(OrderSelect(tempin_6, 0, 0)))
      continue;

    if ((OrderSymbol() != tempst_4 && tempst_4 != ""))
      continue;

    if ((tempin_3 >= 0 && OrderType() != tempin_3))
      continue;

    if ((OrderType() != 0 && OrderType() != 1))
      continue;

    if ((tempin_2 >= 0 && OrderMagicNumber() != tempin_2))
      continue;
    tempdo_5 = OrderProfit() + OrderCommission() + OrderSwap() + tempdo_5;
  }
  localDouble_2 = tempdo_5;
  tempin_8 = -1;
  tempin_9 = -1;
  tempst_10 = localString_1;
  tempdo_11 = 0.0;
  tempin_12 = 0;
  tempin_13 = OrdersTotal();
  if (localString_1 == "0")
  {
    tempst_10 = g_CurrentSymbol;
  }
  for (tempin_12 = 0; tempin_12 < tempin_13; tempin_12 = tempin_12 + 1)
  {
    if (!(OrderSelect(tempin_12, 0, 0)))
      continue;

    if ((OrderSymbol() != tempst_10 && tempst_10 != ""))
      continue;

    if ((OrderType() != 0 && OrderType() != 1))
      continue;

    if ((tempin_9 >= 0 && OrderType() != tempin_9))
      continue;

    if ((tempin_8 >= 0 && OrderMagicNumber() != tempin_8))
      continue;
    tempdo_11 = tempdo_11 + OrderLots();
  }
  localDouble_3 = tempdo_11;
  if (SymbolInfoDouble(localString_1, 16) == 0.0)
  {
    tempdo_14 = 0.0;
  }
  else
  {
    tempdo_15 = 0.0;
    if (AccountEquity() > 0.0)
    {
      tempdo_15 = MarketInfo(localString_1, 9) / SymbolInfoDouble(localString_1, 16) * MarketInfo(localString_1, 16) * int(localDouble_3) / AccountEquity();
    }
    tempdo_14 = tempdo_15;
  }
  localDouble_4 = tempdo_14;
  if (AccountBalance() > 0.0)
  {
    tempdo_16 = localDouble_2 / AccountBalance();
  }
  else
  {
    tempdo_16 = 0.0;
  }
  localDouble_5 = tempdo_16;
  localDouble_6 = SymbolInfoInteger(NULL, 18);
  localDouble_7 = AccountInfoDouble(ACCOUNT_BALANCE);
  localString_8 = DoubleToString(localDouble_7, 0);
  localString_9 = DoubleToString(localDouble_7 + virtBalance, 0);
  localString_10 = DoubleToString(AccountEquity() + virtBalance, 0);
  if (SymbolInfoDouble("USDCAD", 16) == 0.0)
  {
    tempdo_17 = 0.0;
  }
  else
  {
    tempdo_18 = 0.0;
    if (1000.0 > 0.0)
    {
      tempdo_18 = MarketInfo("USDCAD", 9) / SymbolInfoDouble("USDCAD", 16) * MarketInfo("USDCAD", 16) * 0.01 / 1000.0;
    }
    tempdo_17 = tempdo_18;
  }
  localDouble_11 = tempdo_17;
  if (localDouble_11 > 0.0)
  {
    localDouble_12 = localDouble_7 / localDouble_11;
    if (AccountInfoString(ACCOUNT_CURRENCY) == "USD")
    {
      tempst_19 = "";
    }
    else
    {
      tempst_19 = " ~$" + DoubleToString(localDouble_12, 0);
    }
    localString_8 += tempst_19;
  }
  if (virtBalance != 0.0 && USD_for_001 > 0.0)
  {
    if (ObjectSetString(0, "FullBalance", OBJPROP_TEXT, localString_9))
    {
      ChartRedraw(0);
    }
    if (ObjectSetString(0, "FullEquity", OBJPROP_TEXT, localString_10))
    {
      ChartRedraw(0);
    }
  }
  if (ObjectSetString(0, "OpenLots", OBJPROP_TEXT, DoubleToString(localDouble_3, 2)))
  {
    ChartRedraw(0);
  }
  if (ObjectSetString(0, "CurrLev", OBJPROP_TEXT, "1:" + DoubleToString(localDouble_4, 1)))
  {
    ChartRedraw(0);
  }
  if (ObjectSetString(0, "FloatProf%", OBJPROP_TEXT, StringFormat("%+.1f%%", localDouble_5 * 100.0)))
  {
    ChartRedraw(0);
  }
  if (ObjectSetString(0, "Balance", OBJPROP_TEXT, localString_8))
  {
    ChartRedraw(0);
  }
  if (ObjectSetString(0, "Equity", OBJPROP_TEXT, DoubleToString(AccountEquity(), 1)))
  {
    ChartRedraw(0);
  }
  if (ObjectSetString(0, "FloatProf", OBJPROP_TEXT, StringFormat("%+.1f", localDouble_2)))
  {
    ChartRedraw(0);
  }
  if (ObjectSetString(0, "TradingMode", OBJPROP_TEXT, GetTradingModeText()))
  {
    ChartRedraw(0);
  }
  if (ObjectSetString(0, "Sizelot", OBJPROP_TEXT, DoubleToString(CalculateLotSize(1.0, false) * MathPow(LotsMartinp, FirstNumberp), 3)))
  {
    ChartRedraw(0);
  }
  if (ObjectSetString(0, "spread", OBJPROP_TEXT, DoubleToString(localDouble_6, 0)))
  {
    ChartRedraw(0);
  }
  tempbo_20 = false;
  if (Period() != 15)
  {
    tempbo_20 = true;
  }
  if (!(IsTradeAllowed()))
  {
    tempbo_20 = true;
  }
  if (AccountInfoInteger(ACCOUNT_TRADE_ALLOWED) == 0)
  {
    tempbo_20 = true;
  }
  if (TerminalInfoInteger(6) == 0)
  {
    tempbo_20 = true;
  }
  if (tempbo_20 == true)
  {
    ObjectSetInteger(0, "RectLabel", OBJPROP_BGCOLOR, 17919);
    return;
  }
  ObjectSetInteger(0, "RectLabel", OBJPROP_BGCOLOR, 8421376);
}
// UpdateDashboardInfo <<==--------   --------
string GetTradingModeText()
{
  string tempst_1;
  long templo_2;
  int tempin_3;
  string tempst_4;
  long templo_5;
  int tempin_6;
  string tempst_7;

  if (TerminalInfoInteger(6) == 0)
  {
    tempst_1 = "No connection";
    return (tempst_1);
  }
  if (AccountInfoInteger(ACCOUNT_TRADE_ALLOWED) == 0)
  {
    tempst_1 = "Investor mode";
    return (tempst_1);
  }
  if (Period() != 15)
  {
    tempst_1 = "Change timeframe to M15";
    return (tempst_1);
  }
  if (!(IsTradeAllowed()))
  {
    tempst_1 = "EA trading not allowed";
    return (tempst_1);
  }
  if (fastClose)
  {
    tempst_1 = "EMERGENCY CLOSING!!!";
    return (tempst_1);
  }
  if (FirstPositionp != 1)
  {
    tempst_1 = "Trade limited. FirstPos=" + EnumToString(FirstPositiontype(FirstPositionp));
    return (tempst_1);
  }
  if (!(g_GridEnabled))
  {
    tempst_1 = "ATR > ATR_max. Only close.";
    return (tempst_1);
  }
  templo_2 = TimeCurrent();
  tempin_3 = 0;
  if (holidays == 0)
  {
    tempin_3 = 15;
  }
  else
  {
    if (holidays == 1)
    {
      tempin_3 = 8;
    }
    else
    {
      tempin_3 = 0;
    }
  }
  if ((TimeDayOfYear(templo_2) < tempin_3 || TimeDayOfYear(templo_2) > 358))
  {
    tempst_4 = "Christmas and NY holidays";
  }
  else
  {
    tempst_4 = "";
  }
  if (tempst_4 != "")
  {
    templo_5 = TimeCurrent();
    tempin_6 = 0;
    if (holidays == 0)
    {
      tempin_6 = 15;
    }
    else
    {
      if (holidays == 1)
      {
        tempin_6 = 8;
      }
      else
      {
        tempin_6 = 0;
      }
    }
    if ((TimeDayOfYear(templo_5) < tempin_6 || TimeDayOfYear(templo_5) > 358))
    {
      tempst_7 = "Christmas and NY holidays";
    }
    else
    {
      tempst_7 = "";
    }
    tempst_1 = tempst_7;
    return (tempst_1);
  }
  if (IsVisualMode())
  {
    tempst_1 = "Backtesting in Visual Mode";
    return (tempst_1);
  }
  tempst_1 = "Live Trading";
  return (tempst_1);
}
// GetTradingModeText <<==--------   --------
void EmergencyHandler(int param0_in)
{
  int localInt_1;
  //----- -----
  string tempst_1;
  string tempst_2;
  string tempst_3;
  g_AdvisorIndex = IntegerToString(param0_in, 2, 48);
  if (StringLen(g_CurrentSymbol) != 6)
  {
    tempst_1 = "99";
  }
  else
  {
    tempst_1 = CurrencyToIndex(StringSubstr(g_CurrentSymbol, 0, 3)) + CurrencyToIndex(StringSubstr(g_CurrentSymbol, 3, 3));
  }
  g_InternalMagic = StringToInteger(tempst_1 + g_AdvisorIndex);
  g_CurrentMagic = GlobalVariableGet(string(IsTesting()) + "Magic" + g_CurrentSymbol + string(g_InternalMagic));
  g_MartinMultiplier = LotsMartinp;
  g_MaxRetries = g_MinPipStep;
  if ((g_SettingsMode != 1 || StringTrimLeft(StringTrimRight(g_CustomSettings)) != ""))
  {
    localInt_1 = param0_in - 1;
    g_MaxRetries = g_SettingsArray[localInt_1].magicNumber;
    g_LotMultiplier = g_SettingsArray[localInt_1].martinMultiplier;
    g_TakeProfit1 = g_SettingsArray[localInt_1].minProfitPercent;
    g_TakeProfit2 = g_SettingsArray[localInt_1].maxDrawdownPercent;
    g_TakeProfitPips = g_SettingsArray[localInt_1].riskPercent;
    g_StopLossMultiplier = g_SettingsArray[localInt_1].tpMultiplier;
    g_Reserved1 = g_SettingsArray[localInt_1].reserved;
  }
  g_CurrentLevel = GlobalVariableGet(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic));
  g_NextEntryPrice = GlobalVariableGet(string(IsTesting()) + "Distance_Price" + g_CurrentSymbol + string(g_InternalMagic));
  g_TickValue = MarketInfo(g_CurrentSymbol, 13);
  g_SpreadValue = MarketInfo(g_CurrentSymbol, 13) * MarketInfo(g_CurrentSymbol, 11);
  g_SwapLong = MarketInfo(g_CurrentSymbol, 10);
  g_SwapShort = MarketInfo(g_CurrentSymbol, 9);
  g_PointValue = MarketInfo(g_CurrentSymbol, 11);
  g_MarginRequired = 0.0;
  if (iClose(g_CurrentSymbol, 0, 1) > 0.0)
  {
    g_MarginRequired = (MathAbs(g_SwapShort / iClose(g_CurrentSymbol, 0, 1) - 1.0)) * 10000.0;
  }
  ResetGlobalVariables();
  if (iATR(g_CurrentSymbol, 1440, g_GridLevels, 1) / MarketInfo(g_CurrentSymbol, 9) > g_MinProfitPercent)
  {
    g_GridEnabled = false;
    return;
  }
  g_GridEnabled = true;
}
// EmergencyHandler <<==--------   --------
void CloseAllPositions()
{
  double localDouble_1;
  //----- -----

  localDouble_1 = GlobalVariableGet(string(IsTesting()) + g_CurrentSymbol + string(g_InternalMagic) + "tp");

  if (CheckOrderExists(g_CurrentSymbol, 0, g_CurrentMagic, 0, "") && g_SwapShort >= localDouble_1 && localDouble_1 != 0.0)
  {
    CloseOrdersByType(g_CurrentSymbol, 0, g_CurrentMagic);
  }
  if (!(CheckOrderExists(g_CurrentSymbol, 1, g_CurrentMagic, 0, "")) || !(g_SwapLong <= localDouble_1))
    return;
  CloseOrdersByType(g_CurrentSymbol, 1, g_CurrentMagic);
}
//<<==CloseAllPositions <<==
string TrimString(string s1)
{
  return (StringTrimLeft(StringTrimRight(s1)));
}

void SplitString(string s1, string s2, string &global_99_st_si11[])
{
  StringSplit(s2, StringGetCharacter(s1, 0), global_99_st_si11);
  int size = ArraySize(global_99_st_si11);
  for (int i = 0; i < size; i++)
  {
    global_99_st_si11[i] = TrimString(global_99_st_si11[i]);
  }
}
//-----
  void ParseSymbolMultipliers(string &symbolList[], double &multiplierList[])
  {
    string separator = "*";
    ushort separatorChar = StringGetCharacter(separator, 0);
    ArrayResize(multiplierList, ArraySize(symbolList), 0);
    for (int i = 0; i < ArraySize(symbolList); i++)
    {
      string symbolParts[2];
      StringSplit(TrimString(symbolList[i]), separatorChar, symbolParts);
      symbolList[i] = symbolParts[0];
      multiplierList[i] = (ArraySize(symbolParts) == 2) ? StringToDouble(symbolParts[1]) : g_MinLotMultiplier;
      Print(symbolList[i], " ", multiplierList[i]);
    }
  }
//----------
void CopySettingsArray(_sets &global_2_a_160_[], _sets &localString_19[])
{
  ArrayResize(global_2_a_160_, ArraySize(localString_19), 0);
  for (int tempin_5 = 0; tempin_5 < ArraySize(localString_19); tempin_5++)
  {
    CopySettingsStruct(global_2_a_160_[tempin_5], localString_19[tempin_5]);
  }
}
//-------------
void CopySettingsStruct(_sets &xx, _sets &CopySettingsStruct)
{
  xx.setName = CopySettingsStruct.setName;
  xx.magicNumber = CopySettingsStruct.magicNumber;
  xx.martinMultiplier = CopySettingsStruct.martinMultiplier;
  xx.minProfitPercent = CopySettingsStruct.minProfitPercent;
  xx.maxDrawdownPercent = CopySettingsStruct.maxDrawdownPercent;
  xx.riskPercent = CopySettingsStruct.riskPercent;
  xx.tpMultiplier = CopySettingsStruct.tpMultiplier;
  xx.reserved = CopySettingsStruct.reserved;
}
//----------
// 检查MarketWatch中是否存在指定的品种（symbol），并返回其标准化名称
string HasOpenOrders(string symbolName)
{
  // 检查传入的品种名长度是否合理
  if (StringLen(symbolName) <= 5)
  {
    Print("Symbol name " + symbolName + " from sets is too short. Perhaps you made a mistake in writing.");
    return ("");
  }

  // 遍历MarketWatch中的所有品种
  for (int symbolIndex = 0; symbolIndex < SymbolsTotal(true); symbolIndex++)
  {
    string marketSymbol = SymbolName(symbolIndex, true); // MarketWatch中的品种名
    string originalMarketSymbol = marketSymbol; // 保留原始品种名用于返回

    // 转为大写进行不区分大小写的比较
    StringToUpper(marketSymbol);
    string symbolNameUpper = symbolName;
    StringToUpper(symbolNameUpper);

    // 如果MarketWatch中的品种名包含传入的品种名，则返回该品种名
    if (StringFind(marketSymbol, symbolNameUpper, 0) >= 0)
    {
      return (originalMarketSymbol);
    }
  }

  // 未找到品种，提示用户添加到MarketWatch
  Print("Symbol " + symbolName + " from sets not found in MarketWatch. Add this symbol to MarketWatch.");
  return ("");
}

//-------------
bool CheckOrderExists(string tempst_8, int tempin_7, int tempin_6, int tempin_5, string tempst_4)
{
  string tempst_9;
  int tempin_10 = 0;
  int tempin_11 = OrdersTotal();
  if (g_CurrentSymbol == "0")
  {
    tempst_8 = g_CurrentSymbol;
  }
  for (tempin_10 = 0; tempin_10 < tempin_11; tempin_10++)
  {
    if (!(OrderSelect(tempin_10, 0, 0)))
      continue;
    if ((OrderSymbol() != tempst_8 && tempst_8 != ""))
      continue;
    if ((StringFind(OrderComment(), tempst_4, 0) < 0 && tempst_4 != ""))
      continue;
    if ((OrderType() != 0 && OrderType() != 1))
      continue;
    if ((tempin_7 >= 0 && OrderType() != tempin_7))
      continue;
    if ((tempin_6 >= 0 && OrderMagicNumber() != tempin_6))
      continue;
    if ((tempin_5 == OrderTicket() || tempin_5 == 0))
    {
      return (true);
    }
  }
  return (false);
}
//----------
double GetOrderComment(string tempst_24, int tempin_23, int tempin_22)
{

  double tempdo_25 = 0.0;
  int tempin_26 = 0;
  int tempin_27 = OrdersTotal();
  if (g_CurrentSymbol == "0")
  {
    tempst_24 = g_CurrentSymbol;
  }
  for (tempin_26 = 0; tempin_26 < tempin_27; tempin_26++)
  {
    if (!(OrderSelect(tempin_26, 0, 0)))
      continue;
    if ((OrderSymbol() != tempst_24 && tempst_24 != ""))
      continue;
    if ((tempin_23 >= 0 && OrderType() != tempin_23))
      continue;
    if ((OrderType() != 0 && OrderType() != 1))
      continue;
    if ((tempin_22 < 0 || OrderMagicNumber() == tempin_22))
    {
      tempdo_25 = OrderProfit() + OrderCommission() + OrderSwap() + tempdo_25;
    }
  }

  return (tempdo_25);
}

//--------------------
void SetVirtualTakeProfit(int tempin_114, int tempin_113, double tempdo_112)
{

  string tempst_115 = g_CurrentSymbol;
  int tempin_116 = 0;
  int tempin_117 = OrdersTotal();
  int tempin_118 = 0;
  if (g_CurrentSymbol == "0")
  {
    tempst_115 = g_CurrentSymbol;
  }
  tempin_116 = 0;
  if (tempin_117 > 0)
  {
    for (; tempin_116 < tempin_117; tempin_116++)
    {
      if (!(OrderSelect(tempin_116, 0, 0)))
        continue;
      tempin_118 = OrderType();
      if (tempin_118 >= 2)
        continue;

      if ((OrderSymbol() != tempst_115 && tempst_115 != ""))
        continue;
      if ((tempin_114 >= 0 && tempin_118 != tempin_114))
        continue;

      if ((tempin_113 >= 0 && OrderMagicNumber() != tempin_113))
        continue;
      ModifyOrder(-1.0, -1.0, tempdo_112, 0);
    }
  }
}
//---------------------
string CheckHolidayRestriction()
{
  datetime templo_42 = TimeCurrent();
  int tempin_43 = 0;
  if (holidays == 0)
  {
    tempin_43 = 15;
  }
  else
  {
    if (holidays == 1)
    {
      tempin_43 = 8;
    }
    else
    {
      tempin_43 = 0;
    }
  }
  if ((TimeDayOfYear(templo_42) < tempin_43 || TimeDayOfYear(templo_42) > 358))
  {
    return ("Christmas and NY holidays");
  }
  return ("");
}
//-----------
int CountOtherMagics(int tempin_46, string tempst_45)
{
  int tempin_48;
  int tempin_47 = OrdersTotal();
  int localInt_15_ko[];
  ArrayResize(localInt_15_ko, 0, 0);
  for (tempin_48 = 0; tempin_48 < tempin_47; tempin_48++)
  {
    if (!(OrderSelect(tempin_48, 0, 0)))
      continue;

    if ((OrderSymbol() != tempst_45 && tempst_45 != ""))
      continue;

    if ((OrderType() != 0 && OrderType() != 1) || OrderMagicNumber() == tempin_46)
      continue;
    int tempin_49 = 0;
    for (int tempin_50 = 0; tempin_50 < ArraySize(localInt_15_ko); tempin_50++)
    {
      if (localInt_15_ko[tempin_50] == OrderMagicNumber())
      {
        tempin_49 = 1;
        break;
      }
    }
    if (tempin_49 == 0)
    {
      ArrayResize(localInt_15_ko, ArraySize(localInt_15_ko) + 1, 0);
      localInt_15_ko[ArraySize(localInt_15_ko) - 1] = OrderMagicNumber();
    }
  }
  return (ArraySize(localInt_15_ko));
}

int CountOtherSymbols(string tempst_52)

{
  int tempin_53 = 0;
  int tempin_54 = OrdersTotal();
  if (g_CurrentSymbol == "0")
  {
    tempst_52 = g_CurrentSymbol;
  }
  string localString_16_ko[];
  ArrayResize(localString_16_ko, 0, 0);
  for (tempin_53 = 0; tempin_53 < tempin_54; tempin_53++)
  {
    if (!(OrderSelect(tempin_53, 0, 0)) || OrderSymbol() == tempst_52)
      continue;
    if ((OrderType() != 0 && OrderType() != 1))
      continue;
    int tempin_55 = 0;
    for (int tempin_56 = 0; tempin_56 < ArraySize(localString_16_ko); tempin_56++)
    {
      if (localString_16_ko[tempin_56] == OrderSymbol())
      {
        tempin_55 = 1;
        break;
      }
    }
    if (tempin_55 == 0)
    {
      ArrayResize(localString_16_ko, ArraySize(localString_16_ko) + 1, 0);
      localString_16_ko[ArraySize(localString_16_ko) - 1] = OrderSymbol();
    }
  }
  return (ArraySize(localString_16_ko));
}
//-------------
void UpdateGridDistance()
{
  string tempst_58 = "C" + IntegerToString(g_CurrentLevel + 1, 0, 32);
  int tempin_59 = 1;
  int tempin_60 = 0;
  double tempdo_61 = g_NextEntryPrice;
  string tempst_62 = IntegerToString(g_CurrentMagic, 0, 32);
  int tempin_63 = (g_CurrentLevel + 1 >= FirstNumberp) ? 255 : 8388736;
  if (tempst_62 == "")
  {
    tempst_62 = DoubleToString(iTime(g_CurrentSymbol, 0, 0), 0);
  }
  if (tempdo_61 <= 0.0)
  {
    tempdo_61 = MarketInfo(g_CurrentSymbol, 9);
  }
  if (ObjectFind(tempst_62) < 0)
  {
    ObjectCreate(tempst_62, 1, 0, 0, 0.0, 0, 0.0, 0, 0.0);
  }
  ObjectSetString(0, tempst_62, OBJPROP_TEXT, tempst_58);
  ObjectSet(tempst_62, 1, tempdo_61);
  ObjectSet(tempst_62, 6, tempin_63);
  ObjectSet(tempst_62, 7, tempin_60);
  ObjectSet(tempst_62, 8, tempin_59);
}
//--------------
double CalculateBreakeven(int tempin_96, int tempin_95)
{

  string tempst_97 = g_CurrentSymbol;
  double tempdo_98 = 0.0;
  double tempdo_99 = 0.0;
  if (g_CurrentSymbol == "")
  {
    tempst_97 = g_CurrentSymbol;
  }
  for (int tempin_100 = OrdersTotal() - 1; tempin_100 >= 0; tempin_100--)
  {
    OrderSelect(tempin_100, 0, 0);
    if (OrderSymbol() != tempst_97 || OrderMagicNumber() != tempin_95)
      continue;

    if ((OrderType() != tempin_96 && tempin_96 != -1) || OrderType() > 1)
      continue;
    tempdo_98 = OrderOpenPrice() * OrderLots() + tempdo_98;
    tempdo_99 = tempdo_99 + OrderLots();
  }
  if (tempdo_99 == 0.0)
  {
    return (0.0);
  }
  else
  {
    return (NormalizeDouble(tempdo_98 / tempdo_99, Digits()));
  }
}

bool CheckDrawdownLimit(int i1)
{
  if (GlobalVariableGet(string(IsTesting()) + g_CurrentSymbol + string(i1) + string(g_InternalMagic)) == 1.0)
  {
    return (true);
  }
  return (false); //
}

bool IsFirstPositionAllowed()
{
  if ((GlobalVariableGet(string(IsTesting()) + g_CurrentSymbol + "0" + string(g_InternalMagic)) == 1.0 || GlobalVariableGet(string(IsTesting()) + g_CurrentSymbol + "1" + string(g_InternalMagic)) == 1.0))
  {
    return (true);
  }
  return (false);
}

double GetMaxOrderLevel(int tempin_2, int tempin_1)
{

  int tempin_3 = 0;
  double tempdo_4 = 0.0;
  double tempdo_5 = 0.0;
  double tempin_6 = MarketInfo(g_CurrentSymbol, 9);
  if (StringFind(g_CurrentSymbol, "AUDCAD", 0) >= 0)
  {
    tempin_3 = 0;
  }
  else
  {
    if (StringFind(g_CurrentSymbol, "AUDNZD", 0) >= 0)
    {
      tempin_3 = 1;
    }
    else
    {
      if (StringFind(g_CurrentSymbol, "NZDCAD", 0) >= 0)
      {
        tempin_3 = 2;
      }
      else
      {
        if (StringFind(g_CurrentSymbol, "GBPCAD", 0) >= 0)
        {
          tempin_3 = 3;
        }
        else
        {
          if (StringFind(g_CurrentSymbol, "EURGBP", 0) >= 0)
          {
            tempin_3 = 4;
          }
          else
          {
            tempin_3 = 5;
          }
        }
      }
    }
  }
  if ((tempin_2 < 0 || tempin_2 > 4 || tempin_3 == -1 || Period() != 15))
  {
    return (-1.0);
  }
  tempdo_4 = g_PriceGridArray[tempin_3][tempin_2][0];
  tempdo_5 = g_PriceGridArray[tempin_3][tempin_2][1];

  return (tempdo_4 * MathPow(tempin_1, tempdo_5) * tempin_6);
}

datetime DELAYtime(string tempst_66, int tempin_65, int tempin_64, string tempst_63, datetime templo_62)
{

  double tempdo_67 = 0;
  int tempin_68 = 0;
  int tempin_69 = OrdersTotal();
  if (g_CurrentSymbol == "0")
  {
    tempst_66 = g_CurrentSymbol;
  }
  for (tempin_68 = 0; tempin_68 < tempin_69; tempin_68++)
  {
    if (!(OrderSelect(tempin_68, 0, 0)))
      continue;

    if ((OrderSymbol() != tempst_66 && tempst_66 != ""))
      continue;

    if ((StringFind(OrderComment(), tempst_63, 0) != -1 && tempst_63 != ""))
      continue;

    if ((OrderType() != 0 && OrderType() != 1))
      continue;

    if ((tempin_65 >= 0 && OrderType() != tempin_65))
      continue;

    if ((tempin_64 >= 0 && OrderMagicNumber() != tempin_64 && OrderMagicNumber() != g_CurrentMagic) || !(tempdo_67 < OrderOpenTime()))
      continue;
    tempdo_67 = OrderOpenTime();
  }
  templo_62 = templo_62 - datetime(tempdo_67);
  return (templo_62);
}

void SetNUMBER(string tempst_56, int tempin_55, int tempin_54)
{
  long tempdo_57 = 0;
  int tempin_58 = 0;
  int tempin_59 = OrdersTotal();
  if (g_CurrentSymbol == "0")
  {
    tempst_56 = g_CurrentSymbol;
  }
  for (tempin_58 = 0; tempin_58 < tempin_59; tempin_58++)
  {
    if (!(OrderSelect(tempin_58, 0, 0)))
      continue;

    if ((OrderSymbol() != tempst_56 && tempst_56 != "") || StringFind(OrderComment(), "_C", 0) == -1)
      continue;

    if ((OrderType() != 0 && OrderType() != 1))
      continue;

    if ((tempin_55 >= 0 && OrderType() != tempin_55))
      continue;

    if ((tempin_54 > 0 || OrderMagicNumber() == tempin_54 || OrderMagicNumber() == g_CurrentMagic))
    {
      long tempdo_60 = StringToInteger(StringSubstr(OrderComment(), StringFind(OrderComment(), "_C", 0) + 2, 0));

      tempdo_57 = (tempdo_60 <= tempdo_57) ? tempdo_60 : tempdo_57;
    }
  }
  GlobalVariableSet(string(IsTesting()) + "NUMBER" + g_CurrentSymbol + string(g_InternalMagic), tempdo_57);
}

string GetSymbolPrefix(string ss11)
{
  if (StringLen(g_CurrentSymbol) != 6)
  {
    return ("99");
  }
  string w1 = StringSubstr(ss11, 0, 3);
  string w2 = StringSubstr(ss11, 3, 3);
  string w3;
  return (CurrencyToIndex(w1) + CurrencyToIndex(w2));
}
string GetMagicSuffix(string ss11)
{
  string s1 = g_CurrentSymbol;
  return (GetSymbolPrefix(s1) + IntegerToString(nmbrThisServer, 2, 48) + ss11);
}

void InitializeTerminal()
{
  if (IsTesting())
  {
    OpenPosition(Symbol(), 0, SymbolInfoDouble(NULL, 34), 0, 0, 123123123, "", 0.0);
    CloseOrdersByType(Symbol(), -1, 123123123);
  }
}

void lizong80(int localInt_8)
{
  if (IsTesting() && g_TesterOption2)
  {
    g_OrderCommentArray[g_OrdersCount] = "C" + string(g_CurrentLevel) + "," + string(g_MaxRetries) + "," + string(g_TotalLots / MarketInfo(g_CurrentSymbol, 9));
    g_OrderTicketArray[g_OrdersCount] = localInt_8;
    g_OrdersCount++;
  }
}